Former-commit-id: 8362e2cf5f892de23616f197db2d383d4f62072a
... | ... |
@@ -100,6 +100,36 @@ reorder.labels.by.size.then.counts = function(counts, z, y, K, L) { |
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
|
103 |
+#' Re-code cluster label by provided mapping scheme |
|
104 |
+#' |
|
105 |
+#' This function will re-code cluster labels based off of a mapping provided by the user, |
|
106 |
+#' for all fields on a celda object involving cluster labels. |
|
107 |
+#' e.g. if Z values range from 1-4 and the user would like all 3's switched to 1's and |
|
108 |
+#' vice versa, this function can be useful. NOTE: it is recommended that this function's results |
|
109 |
+#' aren't used to overwrite the original celda model object provided, in the event of a mis-mapping. |
|
110 |
+#' |
|
111 |
+#' @param celda.mod An object of class celda_C, celda_G, or celda_CG |
|
112 |
+#' @param from A numeric vector of the "keys", corresponding to the "values" in the to parameter |
|
113 |
+#' @param to A numeric vector of the "values"; what each corresponding number in "from" should be mapped to |
|
114 |
+#' @export |
|
115 |
+recode_cluster_labels = function(celda.mod, from, to) { |
|
116 |
+ # Make sure that every value gets a replacement |
|
117 |
+ if (length(setdiff(from, to)) != 0) { |
|
118 |
+ stop("All values in 'from' must have a mapping in 'to'") |
|
119 |
+ } |
|
120 |
+ |
|
121 |
+ if (class(celda.mod) %in% c("celda_C", "celda_CG")) { |
|
122 |
+ celda.mod$z = plyr::mapvalues(celda.mod$z, from, to) |
|
123 |
+ celda.mod$z.probability = celda.mod$z.probability[, to] |
|
124 |
+ } |
|
125 |
+ if (class(celda.mod) %in% c("celda_G", "celda_CG")) { |
|
126 |
+ celda.mod$y = plyr::mapvalues(celda.mod$y, from, to) |
|
127 |
+ celda.mod$y.probability = celda.mod$y.probability[, to] |
|
128 |
+ } |
|
129 |
+ return(celda.mod) |
|
130 |
+} |
|
131 |
+ |
|
132 |
+ |
|
103 | 133 |
#' Check whether a count matrix was the one used in a given celda run |
104 | 134 |
#' |
105 | 135 |
#' Compare the MD5 checksum of a provided count.matrix to the count matrix |
106 | 136 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,22 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/celda_functions.R |
|
3 |
+\name{recode_cluster_labels} |
|
4 |
+\alias{recode_cluster_labels} |
|
5 |
+\title{Re-code cluster label by provided mapping scheme} |
|
6 |
+\usage{ |
|
7 |
+recode_cluster_labels(celda.mod, from, to) |
|
8 |
+} |
|
9 |
+\arguments{ |
|
10 |
+\item{celda.mod}{An object of class celda_C, celda_G, or celda_CG} |
|
11 |
+ |
|
12 |
+\item{from}{A numeric vector of the "keys", corresponding to the "values" in the to parameter} |
|
13 |
+ |
|
14 |
+\item{to}{A numeric vector of the "values"; what each corresponding number in "from" should be mapped to} |
|
15 |
+} |
|
16 |
+\description{ |
|
17 |
+This function will re-code cluster labels based off of a mapping provided by the user, |
|
18 |
+for all fields on a celda object involving cluster labels. |
|
19 |
+e.g. if Z values range from 1-4 and the user would like all 3's switched to 1's and |
|
20 |
+vice versa, this function can be useful. NOTE: it is recommended that this function's results |
|
21 |
+aren't used to overwrite the original celda model object provided, in the event of a mis-mapping. |
|
22 |
+} |