Browse code

fix check warn & notes

ShixiangWang authored on 29/01/2024 06:59:20
Showing 6 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: cellscape
2 2
 Title: Explores single cell copy number profiles in the context of a
3 3
 single cell tree
4
-Version: 1.27.0
4
+Version: 1.28.0
5 5
 Authors@R: c(
6 6
 person("Shixiang", "Wang", , "w_shixiang@163.com", role = c("aut", "cre"),
7 7
 comment = c(ORCID = "0000-0001-9855-7357")),
... ...
@@ -27,7 +27,6 @@ Imports:
27 27
 gtools (>= 3.5.0),
28 28
 htmlwidgets (>= 0.5),
29 29
 jsonlite (>= 0.9.19),
30
- plyr (>= 1.8.3),
31 30
 reshape2 (>=
32 31
 1.4.1),
33 32
 stringr (>= 1.0.0)
... ...
@@ -39,4 +38,4 @@ VignetteBuilder:
39 38
 biocViews: Visualization
40 39
 Encoding: UTF-8
41 40
 LazyData: true
42
-RoxygenNote: 6.0.1
41
+RoxygenNote: 7.2.3
... ...
@@ -16,3 +16,11 @@ export(getMutationsData)
16 16
 export(renderCnvTree)
17 17
 export(replaceSpaces)
18 18
 import(htmlwidgets)
19
+importFrom(reshape2,melt)
20
+importFrom(stats,coef)
21
+importFrom(stats,dist)
22
+importFrom(stats,hclust)
23
+importFrom(stats,lm)
24
+importFrom(stats,na.omit)
25
+importFrom(stats,setNames)
26
+importFrom(utils,combn)
... ...
@@ -56,7 +56,9 @@
56 56
 #'
57 57
 #'
58 58
 #' @import htmlwidgets
59
-#'
59
+#' @importFrom stats coef dist hclust lm na.omit setNames
60
+#' @importFrom utils combn
61
+#' @importFrom reshape2 melt
60 62
 #' @param cnv_data \code{data.frame}
61 63
 #' (Required if not providing mut_data nor mut_data_matrix)
62 64
 #' Single cell copy number segments data. Note that every single cell id
... ...
@@ -916,7 +918,12 @@ cellscape <- function(cnv_data = NULL,
916 918
 #' @export
917 919
 #' @rdname helpers
918 920
 #' @examples
919
-#' dfs_tree(data.frame(source = c("1", "1", "2", "2", "5", "6"), target = c("2", "5", "3", "4", "6", "7")), "1", c())
921
+#' dfs_tree(
922
+#' data.frame(
923
+#' source = c("1", "1", "2", "2", "5", "6"),
924
+#' target = c("2", "5", "3", "4", "6", "7")
925
+#' ), "1", c()
926
+#' )
920 927
 dfs_tree <- function(edges, cur_root, dfs_arr) {
921 928
 if (!is.null(cur_root)) {
922 929
 # add this root to the dfs list of nodes
... ...
@@ -1329,7 +1336,7 @@ processUserData <- function(clonal_prev,
1329 1336
 perturbations <- checkPerts(perturbations)
1330 1337
 
1331 1338
 # MUTATIONS DATA
1332
- mut_data <- getMutationsData(mutations, tree_edges, clonal_prev)
1339
+ mut_data <- getMutationsData(mutations, tree_edges, clonal_prev, show_warnings)
1333 1340
 mutation_info <- mut_data$mutation_info
1334 1341
 mutation_prevalences <- mut_data$mutation_prevalences
1335 1342
 if (is.data.frame(mutations)) {
... ...
@@ -1410,12 +1417,26 @@ checkMinDims <- function(mutations, height, width) {
1410 1417
 #' @param tree_edges -- tree_edges provided by user
1411 1418
 #' @examples
1412 1419
 #' checkRequiredInputs(
1413
-#' data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1", "2", "3", "4", "5", "6", "7"), clonal_prev = c("0.1", "0.22", "0.08", "0.53", "0.009", "0.061", "1")),
1414
-#' data.frame(source = c("1", "1", "2", "2", "5", "6"), target = c("2", "5", "3", "4", "6", "7"))
1420
+#' data.frame(
1421
+#' timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
1422
+#' clone_id = c("1", "2", "3", "4", "5", "6", "7"),
1423
+#' clonal_prev = c("0.1", "0.22", "0.08", "0.53", "0.009", "0.061", "1")
1424
+#' ),
1425
+#' data.frame(
1426
+#' source = c("1", "1", "2", "2", "5", "6"),
1427
+#' target = c("2", "5", "3", "4", "6", "7")
1428
+#' )
1415 1429
 #' )
1416 1430
 #' checkRequiredInputs(
1417
-#' data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1", "2", "3", "4", "5", "6", "7"), clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")),
1418
-#' data.frame(source = c("1", "1", "2", "2", "5", "6"), target = c("2", "5", "3", "4", "6", "7"))
1431
+#' data.frame(
1432
+#' timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
1433
+#' clone_id = c("1", "2", "3", "4", "5", "6", "7"),
1434
+#' clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")
1435
+#' ),
1436
+#' data.frame(
1437
+#' source = c("1", "1", "2", "2", "5", "6"),
1438
+#' target = c("2", "5", "3", "4", "6", "7")
1439
+#' )
1419 1440
 #' )
1420 1441
 #' @export
1421 1442
 #' @rdname helpers
... ...
@@ -1476,7 +1497,12 @@ checkClonalPrev <- function(clonal_prev) {
1476 1497
 #'
1477 1498
 #' @param tree_edges -- tree edges provided by user
1478 1499
 #' @examples
1479
-#' checkTreeEdges(data.frame(source = c("1", "1", "2", "2", "5", "6"), target = c("2", "5", "3", "4", "6", "7")))
1500
+#' checkTreeEdges(
1501
+#' data.frame(
1502
+#' source = c("1", "1", "2", "2", "5", "6"),
1503
+#' target = c("2", "5", "3", "4", "6", "7")
1504
+#' )
1505
+#' )
1480 1506
 #' @export
1481 1507
 #' @rdname helpers
1482 1508
 checkTreeEdges <- function(tree_edges) {
... ...
@@ -1540,7 +1566,12 @@ checkGtypePositioning <- function(genotype_position) {
1540 1566
 #'
1541 1567
 #' @param clone_colours -- clone_colours provided by user
1542 1568
 #' @examples
1543
-#' checkCloneColours(data.frame(clone_id = c("1", "2", "3", "4"), colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")))
1569
+#' checkCloneColours(
1570
+#' data.frame(
1571
+#' clone_id = c("1", "2", "3", "4"),
1572
+#' colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")
1573
+#' )
1574
+#' )
1544 1575
 #' @export
1545 1576
 #' @rdname helpers
1546 1577
 checkCloneColours <- function(clone_colours) {
... ...
@@ -1589,13 +1620,23 @@ checkPerts <- function(perturbations) {
1589 1620
 #' @param clonal_prev -- clonal prevalence data from user
1590 1621
 #' @examples
1591 1622
 #' getMutationsData(
1592
-#' data.frame(chrom = c("11"), coord = c(104043), VAF = c(0.1), clone_id = c(1), timepoint = c("Relapse")),
1593
-#' data.frame(source = c("1", "1", "2", "2", "5", "6"), target = c("2", "5", "3", "4", "6", "7")),
1594
-#' data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1", "2", "3", "4", "5", "6", "7"), clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1"))
1623
+#' data.frame(
1624
+#' chrom = c("11"), coord = c(104043), VAF = c(0.1),
1625
+#' clone_id = c(1), timepoint = c("Relapse")
1626
+#' ),
1627
+#' data.frame(
1628
+#' source = c("1", "1", "2", "2", "5", "6"),
1629
+#' target = c("2", "5", "3", "4", "6", "7")
1630
+#' ),
1631
+#' data.frame(
1632
+#' timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
1633
+#' clone_id = c("1", "2", "3", "4", "5", "6", "7"),
1634
+#' clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")
1635
+#' )
1595 1636
 #' )
1596 1637
 #' @export
1597 1638
 #' @rdname helpers
1598
-getMutationsData <- function(mutations, tree_edges, clonal_prev) {
1639
+getMutationsData <- function(mutations, tree_edges, clonal_prev, show_warnings = TRUE) {
1599 1640
 if (is.data.frame(mutations)) {
1600 1641
 # ensure column names are correct
1601 1642
 if (!("chrom" %in% colnames(mutations)) ||
... ...
@@ -1712,11 +1753,27 @@ getMutationsData <- function(mutations, tree_edges, clonal_prev) {
1712 1753
 #' @rdname helpers
1713 1754
 #' @examples
1714 1755
 #' replaceSpaces(
1715
-#' mutations = data.frame(chrom = c("11"), coord = c(104043), VAF = c(0.1), clone_id = c(1), timepoint = c("Relapse")),
1716
-#' tree_edges = data.frame(source = c("1", "1", "2", "2", "5", "6"), target = c("2", "5", "3", "4", "6", "7")),
1717
-#' clonal_prev = data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1", "2", "3", "4", "5", "6", "7"), clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")),
1718
-#' mutation_prevalences = list("X:6154028" = data.frame(timepoint = c("Diagnosis"), VAF = c(0.5557))), mutation_info = data.frame(clone_id = c(1)),
1719
-#' clone_colours = data.frame(clone_id = c("1", "2", "3", "4"), colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4"))
1756
+#' mutations = data.frame(
1757
+#' chrom = c("11"), coord = c(104043),
1758
+#' VAF = c(0.1), clone_id = c(1), timepoint = c("Relapse")
1759
+#' ),
1760
+#' tree_edges = data.frame(
1761
+#' source = c("1", "1", "2", "2", "5", "6"),
1762
+#' target = c("2", "5", "3", "4", "6", "7")
1763
+#' ),
1764
+#' clonal_prev = data.frame(
1765
+#' timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
1766
+#' clone_id = c("1", "2", "3", "4", "5", "6", "7"),
1767
+#' clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")
1768
+#' ),
1769
+#' mutation_prevalences = list(
1770
+#' "X:6154028" = data.frame(timepoint = c("Diagnosis"), VAF = c(0.5557))
1771
+#' ),
1772
+#' mutation_info = data.frame(clone_id = c(1)),
1773
+#' clone_colours = data.frame(
1774
+#' clone_id = c("1", "2", "3", "4"),
1775
+#' colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")
1776
+#' )
1720 1777
 #' )
1721 1778
 replaceSpaces <- function(clonal_prev, tree_edges, clone_colours, mutation_info, mutations, mutation_prevalences) {
1722 1779
 # create map of original sample ids to space-replaced sample ids
1723 1780
new file mode 100644
... ...
@@ -0,0 +1,6 @@
1
+utils::globalVariables(
2
+ c("VAF", "chr", "chrom_index", "coord", "copy_number",
3
+ "cumsum_values", "genotype", "mode_cnv", "n",
4
+ "n_gt", "px", "px_width", "sc_id", "single_cell_id", "site",
5
+ "timepoint")
6
+)
0 7
\ No newline at end of file
... ...
@@ -4,18 +4,33 @@
4 4
 \alias{cellscape}
5 5
 \title{CellScape}
6 6
 \usage{
7
-cellscape(cnv_data = NULL, mut_data = NULL, mut_data_matrix = NULL,
8
- mut_order = NULL, tree_edges, gtype_tree_edges = NULL, sc_annot = NULL,
9
- clone_colours = "NA", timepoint_title = "Timepoint",
10
- clone_title = "Clone", xaxis_title = "Time Point",
11
- yaxis_title = "Clonal Prevalence", phylogeny_title = "Clonal Phylogeny",
12
- value_type = NULL, node_type = "Cell", display_node_ids = FALSE,
13
- prop_of_clone_threshold = 0.2, vaf_threshold = 0.05,
14
- show_warnings = TRUE, width = 900, height = 800)
7
+cellscape(
8
+ cnv_data = NULL,
9
+ mut_data = NULL,
10
+ mut_data_matrix = NULL,
11
+ mut_order = NULL,
12
+ tree_edges,
13
+ gtype_tree_edges = NULL,
14
+ sc_annot = NULL,
15
+ clone_colours = "NA",
16
+ timepoint_title = "Timepoint",
17
+ clone_title = "Clone",
18
+ xaxis_title = "Time Point",
19
+ yaxis_title = "Clonal Prevalence",
20
+ phylogeny_title = "Clonal Phylogeny",
21
+ value_type = NULL,
22
+ node_type = "Cell",
23
+ display_node_ids = FALSE,
24
+ prop_of_clone_threshold = 0.2,
25
+ vaf_threshold = 0.05,
26
+ show_warnings = TRUE,
27
+ width = 900,
28
+ height = 800
29
+)
15 30
 }
16 31
 \arguments{
17
-\item{cnv_data}{\code{data.frame} 
18
- (Required if not providing mut_data nor mut_data_matrix) 
32
+\item{cnv_data}{\code{data.frame}
33
+ (Required if not providing mut_data nor mut_data_matrix)
19 34
 Single cell copy number segments data. Note that every single cell id
20 35
 must be present in the tree_edges data frame. Required columns are:
21 36
 \describe{
... ...
@@ -32,9 +47,9 @@ cellscape(cnv_data = NULL, mut_data = NULL, mut_data_matrix = NULL,
32 47
 
33 48
 }}
34 49
 
35
-\item{mut_data}{\code{data.frame} 
36
- (Required if not providing cnv_data nor mut_data_matrix) 
37
- Single cell targeted mutation data frame. Note that every single cell id 
50
+\item{mut_data}{\code{data.frame}
51
+ (Required if not providing cnv_data nor mut_data_matrix)
52
+ Single cell targeted mutation data frame. Note that every single cell id
38 53
 must be present in the tree_edges data frame. Required columns are:
39 54
 \describe{
40 55
 
... ...
@@ -48,22 +63,22 @@ cellscape(cnv_data = NULL, mut_data = NULL, mut_data_matrix = NULL,
48 63
 
49 64
 }}
50 65
 
51
-\item{mut_data_matrix}{\code{matrix} 
52
-(Required if not providing cnv_data nor mut_data) 
53
-Single cell targeted mutation matrix. Rows are single cell IDs, 
54
-columns are mutations. Rows and columns must be named, column names 
55
-in the format "<chromosome>:<coordinate>". 
56
-Note that the order of these rows and columns will not be 
57
-preserved, unless mutation order is the same as that specified in the 
58
-mut_order parameter. Also note that every single cell id must be 
66
+\item{mut_data_matrix}{\code{matrix}
67
+(Required if not providing cnv_data nor mut_data)
68
+Single cell targeted mutation matrix. Rows are single cell IDs,
69
+columns are mutations. Rows and columns must be named, column names
70
+in the format "<chromosome>:<coordinate>".
71
+Note that the order of these rows and columns will not be
72
+preserved, unless mutation order is the same as that specified in the
73
+mut_order parameter. Also note that every single cell id must be
59 74
 present in the tree_edges data frame.}
60 75
 
61
-\item{mut_order}{\code{vector} (Optional) Mutation order for targeted 
62
-mutation heatmap (each mutation should consist of a string in the 
63
-form "chrom:coord"). Default will use a clustering function to 
76
+\item{mut_order}{\code{vector} (Optional) Mutation order for targeted
77
+mutation heatmap (each mutation should consist of a string in the
78
+form "chrom:coord"). Default will use a clustering function to
64 79
 determine mutation order.}
65 80
 
66
-\item{tree_edges}{\code{data.frame} Edges for the single cell phylogenetic 
81
+\item{tree_edges}{\code{data.frame} Edges for the single cell phylogenetic
67 82
 tree. Required columns are:
68 83
 \describe{
69 84
 
... ...
@@ -79,7 +94,7 @@ determine mutation order.}
79 94
 
80 95
 }}
81 96
 
82
-\item{gtype_tree_edges}{\code{data.frame} (Required for TimeScape) Genotype 
97
+\item{gtype_tree_edges}{\code{data.frame} (Required for TimeScape) Genotype
83 98
 tree edges of a rooted tree. Required columns are:
84 99
 \describe{
85 100
 
... ...
@@ -89,7 +104,7 @@ determine mutation order.}
89 104
 
90 105
 }}
91 106
 
92
-\item{sc_annot}{\code{data.frame} (Required for TimeScape) Annotations 
107
+\item{sc_annot}{\code{data.frame} (Required for TimeScape) Annotations
93 108
 (genotype and sample id) for each single cell. Required columns are:
94 109
 \describe{
95 110
 
... ...
@@ -101,57 +116,57 @@ determine mutation order.}
101 116
 Optional columns are:
102 117
 \describe{
103 118
 
104
- \item{timepoint:}{\code{character()} id of the sampled time point. 
119
+ \item{timepoint:}{\code{character()} id of the sampled time point.
105 120
 Note: time points will be ordered alphabetically. }
106 121
 
107 122
 }}
108 123
 
109
-\item{clone_colours}{\code{data.frame} (Optional) Clone ids and their 
124
+\item{clone_colours}{\code{data.frame} (Optional) Clone ids and their
110 125
 corresponding colours (in hex format). Required columns are:
111 126
 \describe{
112 127
 
113 128
 \item{clone_id:}{\code{character()} clone id.}
114 129
 
115
- \item{colour:}{\code{character()} the corresponding Hex colour 
130
+ \item{colour:}{\code{character()} the corresponding Hex colour
116 131
 for each clone id.}
117 132
 
118 133
 }}
119 134
 
120
-\item{timepoint_title}{\code{character()} (Optional) Legend title for 
135
+\item{timepoint_title}{\code{character()} (Optional) Legend title for
121 136
 timepoint groups. Default is "Timepoint".}
122 137
 
123
-\item{clone_title}{\code{character()} (Optional) Legend title for clones. 
138
+\item{clone_title}{\code{character()} (Optional) Legend title for clones.
124 139
 Default is "Clone".}
125 140
 
126
-\item{xaxis_title}{\code{character()} (Optional) For TimeScape - x-axis title. 
141
+\item{xaxis_title}{\code{character()} (Optional) For TimeScape - x-axis title.
127 142
 Default is "Time Point".}
128 143
 
129
-\item{yaxis_title}{\code{character()} (Optional) For TimeScape - y-axis title. 
144
+\item{yaxis_title}{\code{character()} (Optional) For TimeScape - y-axis title.
130 145
 Default is "Clonal Prevalence".}
131 146
 
132
-\item{phylogeny_title}{\code{character()} (Optional) For TimeScape - legend 
147
+\item{phylogeny_title}{\code{character()} (Optional) For TimeScape - legend
133 148
 phylogeny title. Default is "Clonal Phylogeny".}
134 149
 
135
-\item{value_type}{\code{character()} (Optional) The type of value plotted in 
136
-heatmap - will affect legend and heatmap tooltips. Default is "VAF" for 
150
+\item{value_type}{\code{character()} (Optional) The type of value plotted in
151
+heatmap - will affect legend and heatmap tooltips. Default is "VAF" for
137 152
 mutation data, and "CNV" for copy number data.}
138 153
 
139
-\item{node_type}{\code{character()} (Optional) The type of node plotted in 
154
+\item{node_type}{\code{character()} (Optional) The type of node plotted in
140 155
 single cell phylogeny - will affect phylogeny tooltips. Default is "Cell".}
141 156
 
142
-\item{display_node_ids}{\code{logical()} (Optional) Whether or not to display 
157
+\item{display_node_ids}{\code{logical()} (Optional) Whether or not to display
143 158
 the single cell ID within the tree nodes. Default is FALSE.}
144 159
 
145
-\item{prop_of_clone_threshold}{\code{numeric()} (Optional) Used for the 
146
-ordering of targeted mutations. The minimum proportion of a clone to have 
147
-a mutation in order to consider the mutation as present within that clone. 
160
+\item{prop_of_clone_threshold}{\code{numeric()} (Optional) Used for the
161
+ordering of targeted mutations. The minimum proportion of a clone to have
162
+a mutation in order to consider the mutation as present within that clone.
148 163
 Default is 0.2.}
149 164
 
150
-\item{vaf_threshold}{\code{numeric()} (Optional) Used for the ordering of 
151
-targeted mutations. The minimum variant allele frequency for a mutation to 
165
+\item{vaf_threshold}{\code{numeric()} (Optional) Used for the ordering of
166
+targeted mutations. The minimum variant allele frequency for a mutation to
152 167
 be considered as present within a single cell. Default is 0.05.}
153 168
 
154
-\item{show_warnings}{\code{logical()} (Optional) Whether or not to show any 
169
+\item{show_warnings}{\code{logical()} (Optional) Whether or not to show any
155 170
 warnings. Default is TRUE.}
156 171
 
157 172
 \item{width}{\code{numeric()} (Optional) Width of the plot.}
... ...
@@ -159,59 +174,59 @@ warnings. Default is TRUE.}
159 174
 \item{height}{\code{numeric()} (Optional) Height of the plot.}
160 175
 }
161 176
 \description{
162
-\code{cellscape} explores single cell copy number profiles in the 
177
+\code{cellscape} explores single cell copy number profiles in the
163 178
 context of a single cell phylogeny.
164 179
 }
165 180
 \details{
166 181
 Interactive components:
167 182
 \enumerate{
168 183
 
169
-\item Mouseover any single cell in the phylogeny to view its 
184
+ \item Mouseover any single cell in the phylogeny to view its
170 185
 corresponding genomic profile in the heatmap, and vice versa.
171 186
 
172
-\item Mouseover any part of the heatmap to view the CNV or VAF 
187
+ \item Mouseover any part of the heatmap to view the CNV or VAF
173 188
 value for that copy number segment or mutation site, respectively.
174 189
 
175
-\item Mouseover any branch of the phylogeny to view downstream 
190
+ \item Mouseover any branch of the phylogeny to view downstream
176 191
 single cells, both in the phylogeny and heatmap.
177 192
 
178
-\item Mouseover any clone to view its corresponding single cells 
193
+ \item Mouseover any clone to view its corresponding single cells
179 194
 in the phylogeny and heatmap.
180 195
 
181
-\item Click any node in the phylogeny to flip the order of its 
196
+ \item Click any node in the phylogeny to flip the order of its
182 197
 descendant branches.
183 198
 
184
-\item Use the selection tool in the tool bar to select single cell 
185
- genomic profiles and view their corresponding single cells in the 
199
+ \item Use the selection tool in the tool bar to select single cell
200
+ genomic profiles and view their corresponding single cells in the
186 201
 phylogeny.
187 202
 
188
-\item Use the tree trimming tool in the tool bar to remove any
203
+ \item Use the tree trimming tool in the tool bar to remove any
189 204
 branch of the phylogeny by clicking it.
190 205
 
191
-\item Use the switch view tool in the tool bar to change the 
192
- phylogeny view from force-directed to unidirectional, and vice 
206
+ \item Use the switch view tool in the tool bar to change the
207
+ phylogeny view from force-directed to unidirectional, and vice
193 208
 versa.
194 209
 
195
-\item Use the re-root phylogeny tool to root the phylogeny at a 
210
+ \item Use the re-root phylogeny tool to root the phylogeny at a
196 211
 clicked node.
197 212
 
198
-\item Use the flip branch tool to vertically rotate any branch by 
213
+ \item Use the flip branch tool to vertically rotate any branch by
199 214
 clicking its root node.
200 215
 
201
-\item If present, use the scale tree/graph tool in the tool bar to 
216
+ \item If present, use the scale tree/graph tool in the tool bar to
202 217
 scale the phylogeny by the provided edge distances.
203 218
 
204
-\item If time-series information is present such that the TimeScape 
205
- is displayed below the CellScape, clones and time points are 
219
+ \item If time-series information is present such that the TimeScape
220
+ is displayed below the CellScape, clones and time points are
206 221
 interactively linked in both views on mouseover.
207 222
 
208
-\item Click the download buttons to download a PNG or SVG of the view.
223
+ \item Click the download buttons to download a PNG or SVG of the view.
209 224
 
210
-}
225
+ }
211 226
 
212 227
 Note:
213 228
 
214
-See TimeScape repo (https://bitbucket.org/MO_BCCRC/timescape) for more 
229
+See TimeScape repo (https://bitbucket.org/MO_BCCRC/timescape) for more
215 230
 information about TimeScape.
216 231
 }
217 232
 \examples{
... ...
@@ -223,50 +238,67 @@ library("cellscape")
223 238
 # EXAMPLE 1 - TARGETED MUTATION DATA
224 239
 
225 240
 # single cell tree edges
226
-tree_edges <- read.csv(system.file("extdata", "targeted_tree_edges.csv", 
227
- package = "cellscape"))
241
+tree_edges <- read.csv(system.file("extdata", "targeted_tree_edges.csv",
242
+ package = "cellscape"
243
+))
228 244
 
229 245
 # targeted mutations
230
-targeted_data <- read.csv(system.file("extdata", "targeted_muts.csv", 
231
- package = "cellscape"))
246
+targeted_data <- read.csv(system.file("extdata", "targeted_muts.csv",
247
+ package = "cellscape"
248
+))
232 249
 
233 250
 # genotype tree edges
234
-gtype_tree_edges <- data.frame("source"=c("Ancestral", "Ancestral", "B",
235
- "C", "D"), "target"=c("A", "B", "C", "D", "E"))
251
+gtype_tree_edges <- data.frame("source" = c(
252
+ "Ancestral", "Ancestral", "B",
253
+ "C", "D"
254
+), "target" = c("A", "B", "C", "D", "E"))
236 255
 
237 256
 # annotations
238
-sc_annot <- read.csv(system.file("extdata", "targeted_annots.csv", 
239
- package = "cellscape"))
257
+sc_annot <- read.csv(system.file("extdata", "targeted_annots.csv",
258
+ package = "cellscape"
259
+))
240 260
 
241 261
 # mutation order
242
-mut_order <- scan(system.file("extdata", "targeted_mut_order.txt", 
243
- package = "cellscape"), what=character())
262
+mut_order <- scan(system.file("extdata", "targeted_mut_order.txt",
263
+ package = "cellscape"
264
+), what = character())
244 265
 
245 266
 # run cellscape
246
-cellscape(mut_data=targeted_data, tree_edges=tree_edges, sc_annot = 
247
- sc_annot, gtype_tree_edges=gtype_tree_edges, mut_order=mut_order)
267
+cellscape(
268
+ mut_data = targeted_data, tree_edges = tree_edges, sc_annot =
269
+ sc_annot, gtype_tree_edges = gtype_tree_edges, mut_order = mut_order
270
+)
248 271
 
249 272
 
250 273
 # EXAMPLE 2 - COPY NUMBER DATA
251 274
 
252 275
 # single cell tree edges
253
-tree_edges <- read.csv(system.file("extdata", "cnv_tree_edges.csv", 
254
- package = "cellscape"))
276
+tree_edges <- read.csv(system.file("extdata", "cnv_tree_edges.csv",
277
+ package = "cellscape"
278
+))
255 279
 
256 280
 # cnv segments data
257
-cnv_data <- read.csv(system.file("extdata", "cnv_data.csv", package = 
258
- "cellscape"))
281
+cnv_data <- read.csv(system.file("extdata", "cnv_data.csv",
282
+ package =
283
+ "cellscape"
284
+))
259 285
 
260 286
 # annotations
261
-sc_annot <- read.csv(system.file("extdata", "cnv_annots.tsv", package = 
262
- "cellscape"), sep="\\t")
287
+sc_annot <- read.csv(system.file("extdata", "cnv_annots.tsv",
288
+ package =
289
+ "cellscape"
290
+), sep = "\t")
263 291
 
264 292
 # custom clone colours
265
-clone_colours <- data.frame( clone_id = c("1","2","3"), 
266
- colour = c("7fc97f", "beaed4", "fdc086"))
293
+clone_colours <- data.frame(
294
+ clone_id = c("1", "2", "3"),
295
+ colour = c("7fc97f", "beaed4", "fdc086")
296
+)
267 297
 
268 298
 # run cellscape
269
-cellscape(cnv_data=cnv_data, tree_edges=tree_edges, sc_annot=sc_annot, 
270
- width=800, height=475, show_warnings=FALSE, 
271
- clone_colours = clone_colours)
299
+cellscape(
300
+ cnv_data = cnv_data, tree_edges = tree_edges, sc_annot = sc_annot,
301
+ width = 800, height = 475, show_warnings = FALSE,
302
+ clone_colours = clone_colours
303
+)
272 304
 }
... ...
@@ -50,9 +50,22 @@ getTargetedHeatmapForEachSC(mut_data, mut_order, heatmapWidth)
50 50
 
51 51
 findMode(x)
52 52
 
53
-processUserData(clonal_prev, tree_edges, mutations, clone_colours, xaxis_title,
54
- yaxis_title, phylogeny_title, alpha, genotype_position, perturbations, sort,
55
- show_warnings, width, height)
53
+processUserData(
54
+ clonal_prev,
55
+ tree_edges,
56
+ mutations,
57
+ clone_colours,
58
+ xaxis_title,
59
+ yaxis_title,
60
+ phylogeny_title,
61
+ alpha,
62
+ genotype_position,
63
+ perturbations,
64
+ sort,
65
+ show_warnings,
66
+ width,
67
+ height
68
+)
56 69
 
57 70
 checkMinDims(mutations, height, width)
58 71
 
... ...
@@ -70,10 +83,16 @@ checkCloneColours(clone_colours)
70 83
 
71 84
 checkPerts(perturbations)
72 85
 
73
-getMutationsData(mutations, tree_edges, clonal_prev)
86
+getMutationsData(mutations, tree_edges, clonal_prev, show_warnings = TRUE)
74 87
 
75
-replaceSpaces(clonal_prev, tree_edges, clone_colours, mutation_info, mutations,
76
- mutation_prevalences)
88
+replaceSpaces(
89
+ clonal_prev,
90
+ tree_edges,
91
+ clone_colours,
92
+ mutation_info,
93
+ mutations,
94
+ mutation_prevalences
95
+)
77 96
 }
78 97
 \arguments{
79 98
 \item{edges}{-- edges of tree}
... ...
@@ -84,9 +103,9 @@ replaceSpaces(clonal_prev, tree_edges, clone_colours, mutation_info, mutations,
84 103
 
85 104
 \item{outputId}{-- id of output}
86 105
 
87
-\item{width}{-- width of output}
106
+\item{width}{-- width provided by user}
88 107
 
89
-\item{height}{-- height of output}
108
+\item{height}{-- height provided by user}
90 109
 
91 110
 \item{expr}{-- expression for Shiny}
92 111
 
... ...
@@ -96,11 +115,11 @@ replaceSpaces(clonal_prev, tree_edges, clone_colours, mutation_info, mutations,
96 115
 
97 116
 \item{hm_sc_ids_ordered}{-- array of single cell ids in order}
98 117
 
99
-\item{ncols}{-- number of columns in heatmap/grid}
118
+\item{ncols}{-- integer of number of columns (pixels) to fill}
100 119
 
101 120
 \item{chroms}{-- vector of chromosome names}
102 121
 
103
-\item{cnv_data}{-- copy number data}
122
+\item{cnv_data}{-- data frame of copy number variant segments data}
104 123
 
105 124
 \item{chrom_bounds}{-- data frame of chromosome boundaries}
106 125
 
... ...
@@ -116,25 +135,13 @@ replaceSpaces(clonal_prev, tree_edges, clone_colours, mutation_info, mutations,
116 135
 
117 136
 \item{x}{-- vector of numbers}
118 137
 
119
-\item{clonal_prev}{-- data frame of Clonal prevalence. Note: timepoints will be alphanumerically sorted in the view.
120
-Format: columns are (1) character() "timepoint" - time point
121
- (2) character() "clone_id" - clone id
122
- (3) numeric() "clonal_prev" - clonal prevalence.}
138
+\item{clonal_prev}{-- clonal_prev data from user}
123 139
 
124
-\item{tree_edges}{-- data frame of Tree edges of a rooted tree.
125
-Format: columns are (1) character() "source" - source node id
126
- (2) character() "target" - target node id.}
140
+\item{tree_edges}{-- tree edges data from user}
127 141
 
128
-\item{mutations}{-- data frame (Optional) of Mutations occurring at each clone. Any additional field will be shown in the mutation table.
129
-Format: columns are (1) character() "chrom" - chromosome number
130
- (2) numeric() "coord" - coordinate of mutation on chromosome
131
- (3) character() "clone_id" - clone id
132
- (4) character() "timepoint" - time point
133
- (5) numeric() "VAF" - variant allele frequency of the mutation in the corresponding timepoint.}
142
+\item{mutations}{-- mutations data from user}
134 143
 
135
-\item{clone_colours}{-- data frame (Optional) of Clone ids and their corresponding colours 
136
-Format: columns are (1) character() "clone_id" - the clone ids
137
- (2) character() "colour" - the corresponding Hex colour for each clone id.}
144
+\item{clone_colours}{-- clone_colours data from user}
138 145
 
139 146
 \item{xaxis_title}{-- String (Optional) of x-axis title. Default is "Time Point".}
140 147
 
... ...
@@ -142,20 +149,14 @@ Format: columns are (1) character() "clone_id" - the clone ids
142 149
 
143 150
 \item{phylogeny_title}{-- String (Optional) of Legend phylogeny title. Default is "Clonal Phylogeny".}
144 151
 
145
-\item{alpha}{-- Number (Optional) of Alpha value for sweeps, range [0, 100].}
152
+\item{alpha}{-- alpha provided by user}
146 153
 
147
-\item{genotype_position}{-- String (Optional) of How to position the genotypes from ["centre", "stack", "space"] 
148
-"centre" -- genotypes are centred with respect to their ancestors
149
-"stack" -- genotypes are stacked such that no genotype is split at any time point
150
-"space" -- genotypes are stacked but with a bit of spacing at the bottom}
154
+\item{genotype_position}{-- genotype_position provided by user}
151 155
 
152
-\item{perturbations}{-- data frame (Optional) of any perturbations that occurred between two time points.
153
-Format: columns are (1) character() "pert_name" - the perturbation name
154
- (2) character() "prev_tp" - the time point (as labelled in clonal prevalence data) 
155
- BEFORE perturbation.}
156
+\item{perturbations}{-- perturbations provided by user}
156 157
 
157
-\item{sort}{-- Boolean (Optional) of whether (TRUE) or not (FALSE) to vertically sort the genotypes by their emergence values (descending). 
158
-Default is FALSE. 
158
+\item{sort}{-- Boolean (Optional) of whether (TRUE) or not (FALSE) to vertically sort the genotypes by their emergence values (descending).
159
+Default is FALSE.
159 160
 Note that genotype sorting will always retain the phylogenetic hierarchy, and this parameter will only affect the ordering of siblings.}
160 161
 
161 162
 \item{show_warnings}{-- Boolean (Optional) of Whether or not to show any warnings. Default is TRUE.}
... ...
@@ -163,60 +164,6 @@ Note that genotype sorting will always retain the phylogenetic hierarchy, and th
163 164
 \item{mutation_info}{-- processed mutation_info}
164 165
 
165 166
 \item{mutation_prevalences}{-- mutation_prevalences data from user}
166
-
167
-\item{chrom_bounds}{-- data frame of chromosome boundaries}
168
-
169
-\item{ncols}{-- integer of number of columns (pixels) to fill}
170
-
171
-\item{chrom_bounds}{-- data frame of chromosome boundaries}
172
-
173
-\item{cnv_data}{-- data frame of copy number variant segments data}
174
-
175
-\item{chrom_bounds}{-- data frame of chromosome boundaries}
176
-
177
-\item{n_bp_per_pixel}{-- integer of number of base pairs per pixel}
178
-
179
-\item{mut_data}{-- data frame of mutations data}
180
-
181
-\item{width}{-- Number (Optional) of width of the plot. Minimum width is 450.}
182
-
183
-\item{height}{-- Number (Optional) of height of the plot. Minimum height with and without mutations is 500 and 260, respectively.}
184
-
185
-\item{mutations}{-- mutations provided by user}
186
-
187
-\item{height}{-- height provided by user}
188
-
189
-\item{width}{-- width provided by user}
190
-
191
-\item{clonal_prev}{-- clonal_prev provided by user}
192
-
193
-\item{tree_edges}{-- tree_edges provided by user}
194
-
195
-\item{alpha}{-- alpha provided by user}
196
-
197
-\item{clonal_prev}{-- clonal prevalence provided by user}
198
-
199
-\item{tree_edges}{-- tree edges provided by user}
200
-
201
-\item{genotype_position}{-- genotype_position provided by user}
202
-
203
-\item{clone_colours}{-- clone_colours provided by user}
204
-
205
-\item{perturbations}{-- perturbations provided by user}
206
-
207
-\item{mutations}{-- mutations data from user}
208
-
209
-\item{tree_edges}{-- tree edges data from user}
210
-
211
-\item{clonal_prev}{-- clonal prevalence data from user}
212
-
213
-\item{clonal_prev}{-- clonal_prev data from user}
214
-
215
-\item{tree_edges}{-- tree edges data from user}
216
-
217
-\item{clone_colours}{-- clone_colours data from user}
218
-
219
-\item{mutations}{-- mutations data from user}
220 167
 }
221 168
 \description{
222 169
 Get depth first search of a tree
... ...
@@ -266,28 +213,91 @@ get mutation data
266 213
 function to replace spaces with underscores in all data frames & keep maps of original names to space-replaced names
267 214
 }
268 215
 \examples{
269
-dfs_tree(data.frame(source = c("1","1","2","2","5","6"), target=c("2","5","3","4","6","7")), "1", c())
270
-cellscapeOutput(1, '100\%', '300px')
271
-cellscapeOutput(1, '80\%', '300px')
272
-findMode(c(1,1,19,1))
216
+dfs_tree(
217
+ data.frame(
218
+ source = c("1", "1", "2", "2", "5", "6"),
219
+ target = c("2", "5", "3", "4", "6", "7")
220
+ ), "1", c()
221
+)
222
+cellscapeOutput(1, "100\%", "300px")
223
+cellscapeOutput(1, "80\%", "300px")
224
+findMode(c(1, 1, 19, 1))
273 225
 checkMinDims(data.frame(chr = c("11"), coord = c(104043), VAF = c(0.1)), "700px", "700px")
274
-checkRequiredInputs(data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1","2","3","4","5","6","7"), clonal_prev = c("0.1","0.22","0.08","0.53","0.009","0.061","1")), 
275
-data.frame(source = c("1","1","2","2","5","6"), target=c("2","5","3","4","6","7")))
276
-checkRequiredInputs(data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1","2","3","4","5","6","7"), clonal_prev = c("0.12","0.12","0.18","0.13","0.009","0.061","1")), 
277
-data.frame(source = c("1","1","2","2","5","6"), target=c("2","5","3","4","6","7")))
226
+checkRequiredInputs(
227
+ data.frame(
228
+ timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
229
+ clone_id = c("1", "2", "3", "4", "5", "6", "7"),
230
+ clonal_prev = c("0.1", "0.22", "0.08", "0.53", "0.009", "0.061", "1")
231
+ ),
232
+ data.frame(
233
+ source = c("1", "1", "2", "2", "5", "6"),
234
+ target = c("2", "5", "3", "4", "6", "7")
235
+ )
236
+)
237
+checkRequiredInputs(
238
+ data.frame(
239
+ timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
240
+ clone_id = c("1", "2", "3", "4", "5", "6", "7"),
241
+ clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")
242
+ ),
243
+ data.frame(
244
+ source = c("1", "1", "2", "2", "5", "6"),
245
+ target = c("2", "5", "3", "4", "6", "7")
246
+ )
247
+)
278 248
 checkAlpha(4)
279 249
 checkAlpha(100)
280
-checkClonalPrev(data.frame(timepoint=c(1), clone_id=c(2), clonal_prev=c(0.1)))
281
-checkTreeEdges(data.frame(source = c("1","1","2","2","5","6"), target=c("2","5","3","4","6","7")))
250
+checkClonalPrev(data.frame(timepoint = c(1), clone_id = c(2), clonal_prev = c(0.1)))
251
+checkTreeEdges(
252
+ data.frame(
253
+ source = c("1", "1", "2", "2", "5", "6"),
254
+ target = c("2", "5", "3", "4", "6", "7")
255
+ )
256
+)
282 257
 checkGtypePositioning("centre")
283
-checkCloneColours(data.frame(clone_id = c("1","2","3", "4"), colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")))
258
+checkCloneColours(
259
+ data.frame(
260
+ clone_id = c("1", "2", "3", "4"),
261
+ colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")
262
+ )
263
+)
284 264
 checkPerts(data.frame(pert_name = c("New Drug"), prev_tp = c("Diagnosis")))
285
-getMutationsData(data.frame(chrom = c("11"), coord = c(104043), VAF = c(0.1), clone_id=c(1), timepoint=c("Relapse")), 
286
-data.frame(source = c("1","1","2","2","5","6"), target=c("2","5","3","4","6","7")), 
287
-data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1","2","3","4","5","6","7"), clonal_prev = c("0.12","0.12","0.18","0.13","0.009","0.061","1")))
288
-replaceSpaces(mutations = data.frame(chrom = c("11"), coord = c(104043), VAF = c(0.1), clone_id=c(1), timepoint=c("Relapse")), 
289
-tree_edges = data.frame(source = c("1","1","2","2","5","6"), target=c("2","5","3","4","6","7")), 
290
-clonal_prev = data.frame(timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)), clone_id = c("1","2","3","4","5","6","7"), clonal_prev = c("0.12","0.12","0.18","0.13","0.009","0.061","1")),
291
-mutation_prevalences = list("X:6154028" = data.frame(timepoint = c("Diagnosis"), VAF = c(0.5557))), mutation_info=data.frame(clone_id=c(1)),
292
-clone_colours = data.frame(clone_id = c("1","2","3", "4"), colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")))
265
+getMutationsData(
266
+ data.frame(
267
+ chrom = c("11"), coord = c(104043), VAF = c(0.1),
268
+ clone_id = c(1), timepoint = c("Relapse")
269
+ ),
270
+ data.frame(
271
+ source = c("1", "1", "2", "2", "5", "6"),
272
+ target = c("2", "5", "3", "4", "6", "7")
273
+ ),
274
+ data.frame(
275
+ timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
276
+ clone_id = c("1", "2", "3", "4", "5", "6", "7"),
277
+ clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")
278
+ )
279
+)
280
+replaceSpaces(
281
+ mutations = data.frame(
282
+ chrom = c("11"), coord = c(104043),
283
+ VAF = c(0.1), clone_id = c(1), timepoint = c("Relapse")
284
+ ),
285
+ tree_edges = data.frame(
286
+ source = c("1", "1", "2", "2", "5", "6"),
287
+ target = c("2", "5", "3", "4", "6", "7")
288
+ ),
289
+ clonal_prev = data.frame(
290
+ timepoint = c(rep("Diagnosis", 6), rep("Relapse", 1)),
291
+ clone_id = c("1", "2", "3", "4", "5", "6", "7"),
292
+ clonal_prev = c("0.12", "0.12", "0.18", "0.13", "0.009", "0.061", "1")
293
+ ),
294
+ mutation_prevalences = list(
295
+ "X:6154028" = data.frame(timepoint = c("Diagnosis"), VAF = c(0.5557))
296
+ ),
297
+ mutation_info = data.frame(clone_id = c(1)),
298
+ clone_colours = data.frame(
299
+ clone_id = c("1", "2", "3", "4"),
300
+ colour = c("#beaed4", "#fdc086", "#beaed4", "#beaed4")
301
+ )
302
+)
293 303
 }