Browse code

Fixed bug in sparse matrix colsums/rowsums. Changed signature of S4 method for perplexity to ANY.

Joshua D. Campbell authored on 11/04/2021 22:10:26
Showing 1 changed files
... ...
@@ -4,7 +4,7 @@
4 4
   } else if (inherits(counts, "matrix") & is.numeric(counts)) {
5 5
     res <- .rowSumByGroupNumeric(counts, group, L)
6 6
   } else if (inherits(counts, "dgCMatrix")) {
7
-    res <- rowSumByGroupSparse(counts, group)
7
+    res <- rowSumByGroupSparse(counts, group, L)
8 8
   } else {
9 9
     stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
10 10
   }
... ...
@@ -17,7 +17,7 @@
17 17
   } else if (inherits(counts, "matrix") & is.numeric(counts)) {
18 18
     res <- .rowSumByGroupChangeNumeric(counts, pcounts, group, pgroup, L)
19 19
   } else if (inherits(counts, "dgCMatrix")) {
20
-    res <- rowSumByGroupChangeSparse(counts, pcounts, group, pgroup)
20
+    res <- rowSumByGroupChangeSparse(counts, pcounts, group, pgroup, L)
21 21
   } else {
22 22
     stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
23 23
   }
... ...
@@ -30,7 +30,7 @@
30 30
   } else if (inherits(counts, "matrix") & is.numeric(counts)) {
31 31
     res <- .colSumByGroupNumeric(counts, group, K)
32 32
   } else if (inherits(counts, "dgCMatrix")) {
33
-    res <- colSumByGroupSparse(counts, group)
33
+    res <- colSumByGroupSparse(counts, group, K)
34 34
   } else {
35 35
     stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
36 36
   }
... ...
@@ -43,7 +43,7 @@
43 43
   } else if (inherits(counts, "matrix") & is.numeric(counts)) {
44 44
     res <- .colSumByGroupChangeNumeric(counts, pcounts, group, pgroup, K)
45 45
   } else if (inherits(counts, "dgCMatrix")) {
46
-    res <- colSumByGroupChangeSparse(counts, pcounts, group, pgroup)
46
+    res <- colSumByGroupChangeSparse(counts, pcounts, group, pgroup, K)
47 47
   } else {
48 48
     stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
49 49
   }
Browse code

Refactored functions performing matrix operations on different classes (sparse, numeric, integer) to be more centralized in the matrixSums.R file.

Joshua D. Campbell authored on 05/04/2021 18:20:44
Showing 1 changed files
... ...
@@ -1,12 +1,66 @@
1
+.rowSumByGroup <- function(counts, group, L) {
2
+  if (inherits(counts, "matrix") & is.integer(counts)) {
3
+    res <- .rowSumByGroupInteger(counts, group, L)
4
+  } else if (inherits(counts, "matrix") & is.numeric(counts)) {
5
+    res <- .rowSumByGroupNumeric(counts, group, L)
6
+  } else if (inherits(counts, "dgCMatrix")) {
7
+    res <- rowSumByGroupSparse(counts, group)
8
+  } else {
9
+    stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
10
+  }
11
+  return(res)
12
+}
13
+
14
+.rowSumByGroupChange <- function(counts, pcounts, group, pgroup, L) {
15
+  if (inherits(counts, "matrix") & is.integer(counts)) {
16
+    res <- .rowSumByGroupChangeInteger(counts, pcounts, group, pgroup, L)
17
+  } else if (inherits(counts, "matrix") & is.numeric(counts)) {
18
+    res <- .rowSumByGroupChangeNumeric(counts, pcounts, group, pgroup, L)
19
+  } else if (inherits(counts, "dgCMatrix")) {
20
+    res <- rowSumByGroupChangeSparse(counts, pcounts, group, pgroup)
21
+  } else {
22
+    stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
23
+  }
24
+  return(res)
25
+}
26
+
27
+.colSumByGroup <- function(counts, group, K) {
28
+  if (inherits(counts, "matrix") & is.integer(counts)) {
29
+    res <- .colSumByGroupInteger(counts, group, K)
30
+  } else if (inherits(counts, "matrix") & is.numeric(counts)) {
31
+    res <- .colSumByGroupNumeric(counts, group, K)
32
+  } else if (inherits(counts, "dgCMatrix")) {
33
+    res <- colSumByGroupSparse(counts, group)
34
+  } else {
35
+    stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
36
+  }
37
+  return(res)
38
+}
39
+
40
+.colSumByGroupChange <- function(counts, pcounts, group, pgroup, K) {
41
+  if (inherits(counts, "matrix") & is.integer(counts)) {
42
+    res <- .colSumByGroupChangeInteger(counts, pcounts, group, pgroup, K)
43
+  } else if (inherits(counts, "matrix") & is.numeric(counts)) {
44
+    res <- .colSumByGroupChangeNumeric(counts, pcounts, group, pgroup, K)
45
+  } else if (inherits(counts, "dgCMatrix")) {
46
+    res <- colSumByGroupChangeSparse(counts, pcounts, group, pgroup)
47
+  } else {
48
+    stop("'counts' must be an integer, numeric, or dgCMatrix matrix.")
49
+  }
50
+  return(res)
51
+}
52
+
53
+
54
+
1 55
 #' @useDynLib celda _rowSumByGroup
2
-.rowSumByGroup <- function(x, group, L) {
56
+.rowSumByGroupInteger <- function(x, group, L) {
3 57
   group <- factor(group, levels = seq(L))
4 58
   res <- .Call("_rowSumByGroup", x, group)
5 59
   return(res)
6 60
 }
7 61
 
8 62
 #' @useDynLib celda _rowSumByGroupChange
9
-.rowSumByGroupChange <- function(x, px, group, pgroup, L) {
63
+.rowSumByGroupChangeInteger <- function(x, px, group, pgroup, L) {
10 64
   group <- factor(group, levels = seq(L))
11 65
   pgroup <- factor(pgroup, levels = seq(L))
12 66
   res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
... ...
@@ -14,14 +68,14 @@
14 68
 }
15 69
 
16 70
 #' @useDynLib celda _colSumByGroup
17
-.colSumByGroup <- function(x, group, K) {
71
+.colSumByGroupInteger <- function(x, group, K) {
18 72
   group <- factor(group, levels = seq(K))
19 73
   res <- .Call("_colSumByGroup", x, group)
20 74
   return(res)
21 75
 }
22 76
 
23 77
 #' @useDynLib celda _colSumByGroupChange
24
-.colSumByGroupChange <- function(x, px, group, pgroup, K) {
78
+.colSumByGroupChangeInteger <- function(x, px, group, pgroup, K) {
25 79
   group <- factor(group, levels = seq(K))
26 80
   pgroup <- factor(pgroup, levels = seq(K))
27 81
   res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
Browse code

Fixed numeric matrix computations in celda_C. Added ability to use numeric and sparse matrices in celda_G and celda_CG

Joshua D. Campbell authored on 05/04/2021 02:40:50
Showing 1 changed files
... ...
@@ -44,16 +44,18 @@
44 44
 }
45 45
 
46 46
 #' @useDynLib celda _rowSumByGroupChange_numeric
47
-.rowSumByGroupChangeNumeric <- function(x, group, L) {
47
+.rowSumByGroupChangeNumeric <- function(x, px, group, pgroup, L) {
48 48
   group <- factor(group, levels = seq(L))
49
-  res <- .Call("_rowSumByGroupChange_numeric", x, group)
49
+  pgroup <- factor(pgroup, levels = seq(L))
50
+  res <- .Call("_rowSumByGroupChange_numeric", x, px, group, pgroup)
50 51
   return(res)
51 52
 }
52 53
 
53 54
 #' @useDynLib celda _colSumByGroupChange_numeric
54
-.colSumByGroupChangeNumeric <- function(x, group, K) {
55
+.colSumByGroupChangeNumeric <- function(x, px, group, pgroup, K) {
55 56
   group <- factor(group, levels = seq(K))
56
-  res <- .Call("_colSumByGroupChange_numeric", x, group)
57
+  pgroup <- factor(pgroup, levels = seq(K))
58
+  res <- .Call("_colSumByGroupChange_numeric", x, px, group, pgroup)
57 59
   return(res)
58 60
 }
59 61
 
Browse code

Added _rowSumByGroupChange_numeric and _colSumByGroupChange_numeric along with corresponding R functions for working with numeric matrices

Joshua D. Campbell authored on 04/04/2021 01:39:55
Showing 1 changed files
... ...
@@ -43,6 +43,20 @@
43 43
   return(res)
44 44
 }
45 45
 
46
+#' @useDynLib celda _rowSumByGroupChange_numeric
47
+.rowSumByGroupChangeNumeric <- function(x, group, L) {
48
+  group <- factor(group, levels = seq(L))
49
+  res <- .Call("_rowSumByGroupChange_numeric", x, group)
50
+  return(res)
51
+}
52
+
53
+#' @useDynLib celda _colSumByGroupChange_numeric
54
+.colSumByGroupChangeNumeric <- function(x, group, K) {
55
+  group <- factor(group, levels = seq(K))
56
+  res <- .Call("_colSumByGroupChange_numeric", x, group)
57
+  return(res)
58
+}
59
+
46 60
 #' @useDynLib celda _perplexityG
47 61
 .perplexityGLogPx <- function(x, phi, psi, group, L) {
48 62
   group <- factor(group, levels = seq(L))
Browse code

Ran styler and fixed lints

Joshua D. Campbell authored on 06/04/2020 23:58:56
Showing 1 changed files
... ...
@@ -1,51 +1,51 @@
1 1
 #' @useDynLib celda _rowSumByGroup
2 2
 .rowSumByGroup <- function(x, group, L) {
3
-    group <- factor(group, levels = seq(L))
4
-    res <- .Call("_rowSumByGroup", x, group)
5
-    return(res)
3
+  group <- factor(group, levels = seq(L))
4
+  res <- .Call("_rowSumByGroup", x, group)
5
+  return(res)
6 6
 }
7 7
 
8 8
 #' @useDynLib celda _rowSumByGroupChange
9 9
 .rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
-    group <- factor(group, levels = seq(L))
11
-    pgroup <- factor(pgroup, levels = seq(L))
12
-    res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
-    return(res)
10
+  group <- factor(group, levels = seq(L))
11
+  pgroup <- factor(pgroup, levels = seq(L))
12
+  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
+  return(res)
14 14
 }
15 15
 
16 16
 #' @useDynLib celda _colSumByGroup
17 17
 .colSumByGroup <- function(x, group, K) {
18
-    group <- factor(group, levels = seq(K))
19
-    res <- .Call("_colSumByGroup", x, group)
20
-    return(res)
18
+  group <- factor(group, levels = seq(K))
19
+  res <- .Call("_colSumByGroup", x, group)
20
+  return(res)
21 21
 }
22 22
 
23 23
 #' @useDynLib celda _colSumByGroupChange
24 24
 .colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
-    group <- factor(group, levels = seq(K))
26
-    pgroup <- factor(pgroup, levels = seq(K))
27
-    res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
-    return(res)
25
+  group <- factor(group, levels = seq(K))
26
+  pgroup <- factor(pgroup, levels = seq(K))
27
+  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
+  return(res)
29 29
 }
30 30
 
31 31
 
32 32
 #' @useDynLib celda _rowSumByGroup_numeric
33 33
 .rowSumByGroupNumeric <- function(x, group, L) {
34
-    group <- factor(group, levels = seq(L))
35
-    res <- .Call("_rowSumByGroup_numeric", x, group)
36
-    return(res)
34
+  group <- factor(group, levels = seq(L))
35
+  res <- .Call("_rowSumByGroup_numeric", x, group)
36
+  return(res)
37 37
 }
38 38
 
39 39
 #' @useDynLib celda _colSumByGroup_numeric
40 40
 .colSumByGroupNumeric <- function(x, group, K) {
41
-    group <- factor(group, levels = seq(K))
42
-    res <- .Call("_colSumByGroup_numeric", x, group)
43
-    return(res)
41
+  group <- factor(group, levels = seq(K))
42
+  res <- .Call("_colSumByGroup_numeric", x, group)
43
+  return(res)
44 44
 }
45 45
 
46 46
 #' @useDynLib celda _perplexityG
47 47
 .perplexityGLogPx <- function(x, phi, psi, group, L) {
48
-    group <- factor(group, levels = seq(L))
49
-    res <- .Call("_perplexityG", x, phi, psi, group)
50
-    return(res)
48
+  group <- factor(group, levels = seq(L))
49
+  res <- .Call("_perplexityG", x, phi, psi, group)
50
+  return(res)
51 51
 }
Browse code

fix function/variable names

zhewa authored on 08/04/2019 18:51:44
Showing 1 changed files
... ...
@@ -30,14 +30,14 @@
30 30
 
31 31
 
32 32
 #' @useDynLib celda _rowSumByGroup_numeric
33
-.rowSumByGroup.numeric <- function(x, group, L) {
33
+.rowSumByGroupNumeric <- function(x, group, L) {
34 34
     group <- factor(group, levels = seq(L))
35 35
     res <- .Call("_rowSumByGroup_numeric", x, group)
36 36
     return(res)
37 37
 }
38 38
 
39 39
 #' @useDynLib celda _colSumByGroup_numeric
40
-.colSumByGroup.numeric <- function(x, group, K) {
40
+.colSumByGroupNumeric <- function(x, group, K) {
41 41
     group <- factor(group, levels = seq(K))
42 42
     res <- .Call("_colSumByGroup_numeric", x, group)
43 43
     return(res)
Browse code

code style reformat initialize_clusters.R file

Irisapo authored on 02/04/2019 19:15:19
Showing 1 changed files
... ...
@@ -44,7 +44,7 @@
44 44
 }
45 45
 
46 46
 #' @useDynLib celda _perplexityG
47
-.perplexityG_logPx <- function(x, phi, psi, group, L) {
47
+.perplexityGLogPx <- function(x, phi, psi, group, L) {
48 48
     group <- factor(group, levels = seq(L))
49 49
     res <- .Call("_perplexityG", x, phi, psi, group)
50 50
     return(res)
Browse code

reformat matrixSums.R file

Irisapo authored on 02/04/2019 18:33:22
Showing 1 changed files
... ...
@@ -1,29 +1,29 @@
1 1
 #' @useDynLib celda _rowSumByGroup
2 2
 .rowSumByGroup <- function(x, group, L) {
3
-    group <- factor(group, levels = 1:L)
3
+    group <- factor(group, levels = seq(L))
4 4
     res <- .Call("_rowSumByGroup", x, group)
5 5
     return(res)
6 6
 }
7 7
 
8 8
 #' @useDynLib celda _rowSumByGroupChange
9 9
 .rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
-    group <- factor(group, levels = 1:L)
11
-    pgroup <- factor(pgroup, levels = 1:L)
10
+    group <- factor(group, levels = seq(L))
11
+    pgroup <- factor(pgroup, levels = seq(L))
12 12
     res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13 13
     return(res)
14 14
 }
15 15
 
16 16
 #' @useDynLib celda _colSumByGroup
17 17
 .colSumByGroup <- function(x, group, K) {
18
-    group <- factor(group, levels = 1:K)
18
+    group <- factor(group, levels = seq(K))
19 19
     res <- .Call("_colSumByGroup", x, group)
20 20
     return(res)
21 21
 }
22 22
 
23 23
 #' @useDynLib celda _colSumByGroupChange
24
-colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
-    group <- factor(group, levels = 1:K)
26
-    pgroup <- factor(pgroup, levels = 1:K)
24
+.colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
+    group <- factor(group, levels = seq(K))
26
+    pgroup <- factor(pgroup, levels = seq(K))
27 27
     res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28 28
     return(res)
29 29
 }
... ...
@@ -31,21 +31,21 @@ colSumByGroupChange <- function(x, px, group, pgroup, K) {
31 31
 
32 32
 #' @useDynLib celda _rowSumByGroup_numeric
33 33
 .rowSumByGroup.numeric <- function(x, group, L) {
34
-    group <- factor(group, levels = 1:L)
34
+    group <- factor(group, levels = seq(L))
35 35
     res <- .Call("_rowSumByGroup_numeric", x, group)
36 36
     return(res)
37 37
 }
38 38
 
39 39
 #' @useDynLib celda _colSumByGroup_numeric
40 40
 .colSumByGroup.numeric <- function(x, group, K) {
41
-    group <- factor(group, levels = 1:K)
41
+    group <- factor(group, levels = seq(K))
42 42
     res <- .Call("_colSumByGroup_numeric", x, group)
43 43
     return(res)
44 44
 }
45 45
 
46 46
 #' @useDynLib celda _perplexityG
47 47
 .perplexityG_logPx <- function(x, phi, psi, group, L) {
48
-    group <- factor(group, levels = 1:L)
48
+    group <- factor(group, levels = seq(L))
49 49
     res <- .Call("_perplexityG", x, phi, psi, group)
50 50
     return(res)
51 51
 }
Browse code

reformat matrixSums.R

Irisapo authored on 02/04/2019 18:24:25
Showing 1 changed files
... ...
@@ -1,51 +1,51 @@
1 1
 #' @useDynLib celda _rowSumByGroup
2
-rowSumByGroup <- function(x, group, L) {
3
-  group <- factor(group, levels=1:L)
4
-  res <- .Call("_rowSumByGroup", x, group)
5
-  return(res)
2
+.rowSumByGroup <- function(x, group, L) {
3
+    group <- factor(group, levels = 1:L)
4
+    res <- .Call("_rowSumByGroup", x, group)
5
+    return(res)
6 6
 }
7 7
 
8 8
 #' @useDynLib celda _rowSumByGroupChange
9
-rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
-  group <- factor(group, levels=1:L)
11
-  pgroup <- factor(pgroup, levels=1:L)  
12
-  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
-  return(res)
9
+.rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
+    group <- factor(group, levels = 1:L)
11
+    pgroup <- factor(pgroup, levels = 1:L)
12
+    res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
+    return(res)
14 14
 }
15 15
 
16 16
 #' @useDynLib celda _colSumByGroup
17
-colSumByGroup <- function(x, group, K) {
18
-  group <- factor(group, levels=1:K)
19
-  res <- .Call("_colSumByGroup", x, group)
20
-  return(res)
17
+.colSumByGroup <- function(x, group, K) {
18
+    group <- factor(group, levels = 1:K)
19
+    res <- .Call("_colSumByGroup", x, group)
20
+    return(res)
21 21
 }
22 22
 
23 23
 #' @useDynLib celda _colSumByGroupChange
24 24
 colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
-  group <- factor(group, levels=1:K)
26
-  pgroup <- factor(pgroup, levels=1:K)    
27
-  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
-  return(res)
25
+    group <- factor(group, levels = 1:K)
26
+    pgroup <- factor(pgroup, levels = 1:K)
27
+    res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
+    return(res)
29 29
 }
30 30
 
31 31
 
32
-#' @useDynLib celda _rowSumByGroup_numeric 
33
-rowSumByGroup.numeric <- function(x, group, L) {
34
-  group <- factor(group, levels=1:L)
35
-  res <- .Call("_rowSumByGroup_numeric", x, group)
36
-  return(res)
32
+#' @useDynLib celda _rowSumByGroup_numeric
33
+.rowSumByGroup.numeric <- function(x, group, L) {
34
+    group <- factor(group, levels = 1:L)
35
+    res <- .Call("_rowSumByGroup_numeric", x, group)
36
+    return(res)
37 37
 }
38 38
 
39 39
 #' @useDynLib celda _colSumByGroup_numeric
40
-colSumByGroup.numeric <- function(x, group, K) {
41
-  group <- factor(group, levels=1:K)
42
-  res <- .Call("_colSumByGroup_numeric", x, group)
43
-  return(res)
40
+.colSumByGroup.numeric <- function(x, group, K) {
41
+    group <- factor(group, levels = 1:K)
42
+    res <- .Call("_colSumByGroup_numeric", x, group)
43
+    return(res)
44 44
 }
45 45
 
46 46
 #' @useDynLib celda _perplexityG
47
-perplexityG_logPx <- function(x, phi, psi, group, L) {
48
-  group <- factor(group, levels=1:L)
49
-  res <- .Call("_perplexityG", x, phi, psi, group)
50
-  return(res)
47
+.perplexityG_logPx <- function(x, phi, psi, group, L) {
48
+    group <- factor(group, levels = 1:L)
49
+    res <- .Call("_perplexityG", x, phi, psi, group)
50
+    return(res)
51 51
 }
Browse code

Added faster perplexity for celda_G

Joshua D. Campbell authored on 14/03/2019 22:19:41
Showing 1 changed files
... ...
@@ -42,3 +42,10 @@ colSumByGroup.numeric <- function(x, group, K) {
42 42
   res <- .Call("_colSumByGroup_numeric", x, group)
43 43
   return(res)
44 44
 }
45
+
46
+#' @useDynLib celda _perplexityG
47
+perplexityG_logPx <- function(x, phi, psi, group, L) {
48
+  group <- factor(group, levels=1:L)
49
+  res <- .Call("_perplexityG", x, phi, psi, group)
50
+  return(res)
51
+}
Browse code

Moved checks for NA in factors down to C-level code to prevent R from crashing during development.

Joshua D. Campbell authored on 08/03/2019 01:54:54
Showing 1 changed files
... ...
@@ -1,9 +1,5 @@
1 1
 #' @useDynLib celda _rowSumByGroup
2 2
 rowSumByGroup <- function(x, group, L) {
3
-  if(any(group > L)) {
4
-    stop("An entry in 'group' is greater than L.")
5
-  }
6
-
7 3
   group <- factor(group, levels=1:L)
8 4
   res <- .Call("_rowSumByGroup", x, group)
9 5
   return(res)
... ...
@@ -11,13 +7,6 @@ rowSumByGroup <- function(x, group, L) {
11 7
 
12 8
 #' @useDynLib celda _rowSumByGroupChange
13 9
 rowSumByGroupChange <- function(x, px, group, pgroup, L) {
14
-  if(any(group > L)) {
15
-    stop("An entry in 'group' is greater than L.")
16
-  }
17
-  if(any(pgroup > L)) {
18
-    stop("An entry in 'pgroup' is greater than L.")
19
-  }
20
-  
21 10
   group <- factor(group, levels=1:L)
22 11
   pgroup <- factor(pgroup, levels=1:L)  
23 12
   res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
... ...
@@ -26,9 +15,6 @@ rowSumByGroupChange <- function(x, px, group, pgroup, L) {
26 15
 
27 16
 #' @useDynLib celda _colSumByGroup
28 17
 colSumByGroup <- function(x, group, K) {
29
-  if(any(group > K)) {
30
-    stop("An entry in 'group' is greater than K.")
31
-  }
32 18
   group <- factor(group, levels=1:K)
33 19
   res <- .Call("_colSumByGroup", x, group)
34 20
   return(res)
... ...
@@ -36,13 +22,6 @@ colSumByGroup <- function(x, group, K) {
36 22
 
37 23
 #' @useDynLib celda _colSumByGroupChange
38 24
 colSumByGroupChange <- function(x, px, group, pgroup, K) {
39
-  if(any(group > K)) {
40
-    stop("An entry in 'group' is greater than K.")
41
-  }
42
-  if(any(pgroup > K)) {
43
-    stop("An entry in 'pgroup' is greater than K.")
44
-  }
45
-  
46 25
   group <- factor(group, levels=1:K)
47 26
   pgroup <- factor(pgroup, levels=1:K)    
48 27
   res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
Browse code

Added functions for recursively splitting modules/cells

Joshua D. Campbell authored on 19/02/2019 16:36:11
Showing 1 changed files
... ...
@@ -1,5 +1,9 @@
1 1
 #' @useDynLib celda _rowSumByGroup
2 2
 rowSumByGroup <- function(x, group, L) {
3
+  if(any(group > L)) {
4
+    stop("An entry in 'group' is greater than L.")
5
+  }
6
+
3 7
   group <- factor(group, levels=1:L)
4 8
   res <- .Call("_rowSumByGroup", x, group)
5 9
   return(res)
... ...
@@ -7,6 +11,13 @@ rowSumByGroup <- function(x, group, L) {
7 11
 
8 12
 #' @useDynLib celda _rowSumByGroupChange
9 13
 rowSumByGroupChange <- function(x, px, group, pgroup, L) {
14
+  if(any(group > L)) {
15
+    stop("An entry in 'group' is greater than L.")
16
+  }
17
+  if(any(pgroup > L)) {
18
+    stop("An entry in 'pgroup' is greater than L.")
19
+  }
20
+  
10 21
   group <- factor(group, levels=1:L)
11 22
   pgroup <- factor(pgroup, levels=1:L)  
12 23
   res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
... ...
@@ -15,6 +26,9 @@ rowSumByGroupChange <- function(x, px, group, pgroup, L) {
15 26
 
16 27
 #' @useDynLib celda _colSumByGroup
17 28
 colSumByGroup <- function(x, group, K) {
29
+  if(any(group > K)) {
30
+    stop("An entry in 'group' is greater than K.")
31
+  }
18 32
   group <- factor(group, levels=1:K)
19 33
   res <- .Call("_colSumByGroup", x, group)
20 34
   return(res)
... ...
@@ -22,6 +36,13 @@ colSumByGroup <- function(x, group, K) {
22 36
 
23 37
 #' @useDynLib celda _colSumByGroupChange
24 38
 colSumByGroupChange <- function(x, px, group, pgroup, K) {
39
+  if(any(group > K)) {
40
+    stop("An entry in 'group' is greater than K.")
41
+  }
42
+  if(any(pgroup > K)) {
43
+    stop("An entry in 'pgroup' is greater than K.")
44
+  }
45
+  
25 46
   group <- factor(group, levels=1:K)
26 47
   pgroup <- factor(pgroup, levels=1:K)    
27 48
   res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
Browse code

Removed mvMult and mvAdd as these will be replaced by equivalent Rcpp functions

Former-commit-id: 3b85eab4542b95b650e97523d85c8e4633689fb3

Joshua D. Campbell authored on 27/08/2018 15:50:35
Showing 1 changed files
... ...
@@ -1,56 +1,44 @@
1
-#' @useDynLib celda _rowSumByGroup
2
-rowSumByGroup <- function(x, group, L) {
3
-  group <- factor(group, levels=1:L)
4
-  res <- .Call("_rowSumByGroup", x, group)
5
-  return(res)
6
-}
7
-
8
-#' @useDynLib celda _rowSumByGroupChange
9
-rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
-  group <- factor(group, levels=1:L)
11
-  pgroup <- factor(pgroup, levels=1:L)  
12
-  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
-  return(res)
14
-}
15
-
16
-#' @useDynLib celda _colSumByGroup
17
-colSumByGroup <- function(x, group, K) {
18
-  group <- factor(group, levels=1:K)
19
-  res <- .Call("_colSumByGroup", x, group)
20
-  return(res)
21
-}
22
-
23
-#' @useDynLib celda _colSumByGroupChange
24
-colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
-  group <- factor(group, levels=1:K)
26
-  pgroup <- factor(pgroup, levels=1:K)    
27
-  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
-  return(res)
29
-}
30
-
31
-
32
-#' @useDynLib celda _rowSumByGroup_numeric 
33
-rowSumByGroup.numeric <- function(x, group, L) {
34
-  group <- factor(group, levels=1:L)
35
-  res <- .Call("_rowSumByGroup_numeric", x, group)
36
-  return(res)
37
-}
38
-
39
-#' @useDynLib celda _colSumByGroup_numeric
40
-colSumByGroup.numeric <- function(x, group, K) {
41
-  group <- factor(group, levels=1:K)
42
-  res <- .Call("_colSumByGroup_numeric", x, group)
43
-  return(res)
44
-}
45
-
46
-#' @useDynLib celda _mvMult
47
-mvMult <- function(x, v, by.row) {
48
-  res <- .Call("_mvMult", x, v, by.row) 
49
-  return(res)
50
-}
51
-
52
-#' @useDynLib celda _mvAdd 
53
-mvAdd <- function(x, v, by.row) {
54
-  res <- .Call("_mvAdd", x, v, by.row)
55
-  return(res)
56
-}
57 1
\ No newline at end of file
2
+#' @useDynLib celda _rowSumByGroup
3
+rowSumByGroup <- function(x, group, L) {
4
+  group <- factor(group, levels=1:L)
5
+  res <- .Call("_rowSumByGroup", x, group)
6
+  return(res)
7
+}
8
+
9
+#' @useDynLib celda _rowSumByGroupChange
10
+rowSumByGroupChange <- function(x, px, group, pgroup, L) {
11
+  group <- factor(group, levels=1:L)
12
+  pgroup <- factor(pgroup, levels=1:L)  
13
+  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
14
+  return(res)
15
+}
16
+
17
+#' @useDynLib celda _colSumByGroup
18
+colSumByGroup <- function(x, group, K) {
19
+  group <- factor(group, levels=1:K)
20
+  res <- .Call("_colSumByGroup", x, group)
21
+  return(res)
22
+}
23
+
24
+#' @useDynLib celda _colSumByGroupChange
25
+colSumByGroupChange <- function(x, px, group, pgroup, K) {
26
+  group <- factor(group, levels=1:K)
27
+  pgroup <- factor(pgroup, levels=1:K)    
28
+  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
29
+  return(res)
30
+}
31
+
32
+
33
+#' @useDynLib celda _rowSumByGroup_numeric 
34
+rowSumByGroup.numeric <- function(x, group, L) {
35
+  group <- factor(group, levels=1:L)
36
+  res <- .Call("_rowSumByGroup_numeric", x, group)
37
+  return(res)
38
+}
39
+
40
+#' @useDynLib celda _colSumByGroup_numeric
41
+colSumByGroup.numeric <- function(x, group, K) {
42
+  group <- factor(group, levels=1:K)
43
+  res <- .Call("_colSumByGroup_numeric", x, group)
44
+  return(res)
45
+}
Browse code

Updated Celda Documentation

Former-commit-id: 0d13df954f67feb43ad6ec77477e2c78a38585a1

Andrew Gregory authored on 15/08/2018 20:22:38
Showing 1 changed files
... ...
@@ -1,56 +1,56 @@
1
-#' @useDynLib celda _rowSumByGroup
2
-rowSumByGroup <- function(x, group, L) {
3
-  group <- factor(group, levels=1:L)
4
-  res <- .Call("_rowSumByGroup", x, group)
5
-  return(res)
6
-}
7
-
8
-#' @useDynLib celda _rowSumByGroupChange
9
-rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
-  group <- factor(group, levels=1:L)
11
-  pgroup <- factor(pgroup, levels=1:L)  
12
-  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
-  return(res)
14
-}
15
-
16
-#' @useDynLib celda _colSumByGroup
17
-colSumByGroup <- function(x, group, K) {
18
-  group <- factor(group, levels=1:K)
19
-  res <- .Call("_colSumByGroup", x, group)
20
-  return(res)
21
-}
22
-
23
-#' @useDynLib celda _colSumByGroupChange
24
-colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
-  group <- factor(group, levels=1:K)
26
-  pgroup <- factor(pgroup, levels=1:K)    
27
-  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
-  return(res)
29
-}
30
-
31
-
32
-#' @useDynLib celda _rowSumByGroup_numeric 
33
-rowSumByGroup.numeric <- function(x, group, L) {
34
-  group <- factor(group, levels=1:L)
35
-  res <- .Call("_rowSumByGroup_numeric", x, group)
36
-  return(res)
37
-}
38
-
39
-#' @useDynLib celda _colSumByGroup_numeric
40
-colSumByGroup.numeric <- function(x, group, K) {
41
-  group <- factor(group, levels=1:K)
42
-  res <- .Call("_colSumByGroup_numeric", x, group)
43
-  return(res)
44
-}
45
-
46
-#' @useDynLib celda _mvMult
47
-mvMult <- function(x, v, by.row) {
48
-  res <- .Call("_mvMult", x, v, by.row) 
49
-  return(res)
50
-}
51
-
52
-#' @useDynLib celda _mvAdd 
53
-mvAdd <- function(x, v, by.row) {
54
-  res <- .Call("_mvAdd", x, v, by.row)
55
-  return(res)
1
+#' @useDynLib celda _rowSumByGroup
2
+rowSumByGroup <- function(x, group, L) {
3
+  group <- factor(group, levels=1:L)
4
+  res <- .Call("_rowSumByGroup", x, group)
5
+  return(res)
6
+}
7
+
8
+#' @useDynLib celda _rowSumByGroupChange
9
+rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
+  group <- factor(group, levels=1:L)
11
+  pgroup <- factor(pgroup, levels=1:L)  
12
+  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13
+  return(res)
14
+}
15
+
16
+#' @useDynLib celda _colSumByGroup
17
+colSumByGroup <- function(x, group, K) {
18
+  group <- factor(group, levels=1:K)
19
+  res <- .Call("_colSumByGroup", x, group)
20
+  return(res)
21
+}
22
+
23
+#' @useDynLib celda _colSumByGroupChange
24
+colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
+  group <- factor(group, levels=1:K)
26
+  pgroup <- factor(pgroup, levels=1:K)    
27
+  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28
+  return(res)
29
+}
30
+
31
+
32
+#' @useDynLib celda _rowSumByGroup_numeric 
33
+rowSumByGroup.numeric <- function(x, group, L) {
34
+  group <- factor(group, levels=1:L)
35
+  res <- .Call("_rowSumByGroup_numeric", x, group)
36
+  return(res)
37
+}
38
+
39
+#' @useDynLib celda _colSumByGroup_numeric
40
+colSumByGroup.numeric <- function(x, group, K) {
41
+  group <- factor(group, levels=1:K)
42
+  res <- .Call("_colSumByGroup_numeric", x, group)
43
+  return(res)
44
+}
45
+
46
+#' @useDynLib celda _mvMult
47
+mvMult <- function(x, v, by.row) {
48
+  res <- .Call("_mvMult", x, v, by.row) 
49
+  return(res)
50
+}
51
+
52
+#' @useDynLib celda _mvAdd 
53
+mvAdd <- function(x, v, by.row) {
54
+  res <- .Call("_mvAdd", x, v, by.row)
55
+  return(res)
56 56
 }
57 57
\ No newline at end of file
Browse code

c functions for multiplication/addition for matrix & vector (#292)

* add c functions for multiplication/addition for matrix & vector

* c functions for multiplication and addition for matrix & vector


Former-commit-id: 21d57f2dea1310d9fed6009235615941f9c2a82a

SYang authored on 31/07/2018 18:52:04 • Sean committed on 31/07/2018 18:52:04
Showing 1 changed files
... ...
@@ -28,3 +28,29 @@ colSumByGroupChange <- function(x, px, group, pgroup, K) {
28 28
   return(res)
29 29
 }
30 30
 
31
+
32
+#' @useDynLib celda _rowSumByGroup_numeric 
33
+rowSumByGroup.numeric <- function(x, group, L) {
34
+  group <- factor(group, levels=1:L)
35
+  res <- .Call("_rowSumByGroup_numeric", x, group)
36
+  return(res)
37
+}
38
+
39
+#' @useDynLib celda _colSumByGroup_numeric
40
+colSumByGroup.numeric <- function(x, group, K) {
41
+  group <- factor(group, levels=1:K)
42
+  res <- .Call("_colSumByGroup_numeric", x, group)
43
+  return(res)
44
+}
45
+
46
+#' @useDynLib celda _mvMult
47
+mvMult <- function(x, v, by.row) {
48
+  res <- .Call("_mvMult", x, v, by.row) 
49
+  return(res)
50
+}
51
+
52
+#' @useDynLib celda _mvAdd 
53
+mvAdd <- function(x, v, by.row) {
54
+  res <- .Call("_mvAdd", x, v, by.row)
55
+  return(res)
56
+}
31 57
\ No newline at end of file
Browse code

Fix argument checking in wrapper (#269)

* Fix parameter checking code in celda wrapper.
* Removing deprecated parameter. Refactoring test.
* Updating documentation.
* Add SummarizedExperiment to Depends.
* Added _ prefix to C function names. Add data.table to namespace


Former-commit-id: f2efa67d604e95f3250f7ec6c4023f944cdcd859

Sean authored on 03/07/2018 20:25:20 • GitHub committed on 03/07/2018 20:25:20
Showing 1 changed files
... ...
@@ -1,30 +1,30 @@
1
-#' @useDynLib celda rowSumByGroup
1
+#' @useDynLib celda _rowSumByGroup
2 2
 rowSumByGroup <- function(x, group, L) {
3 3
   group <- factor(group, levels=1:L)
4
-  res <- .Call("rowSumByGroup", x, group)
4
+  res <- .Call("_rowSumByGroup", x, group)
5 5
   return(res)
6 6
 }
7 7
 
8
-#' @useDynLib celda rowSumByGroupChange
8
+#' @useDynLib celda _rowSumByGroupChange
9 9
 rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10 10
   group <- factor(group, levels=1:L)
11 11
   pgroup <- factor(pgroup, levels=1:L)  
12
-  res <- .Call("rowSumByGroupChange", x, px, group, pgroup)
12
+  res <- .Call("_rowSumByGroupChange", x, px, group, pgroup)
13 13
   return(res)
14 14
 }
15 15
 
16
-#' @useDynLib celda colSumByGroup
16
+#' @useDynLib celda _colSumByGroup
17 17
 colSumByGroup <- function(x, group, K) {
18 18
   group <- factor(group, levels=1:K)
19
-  res <- .Call("colSumByGroup", x, group)
19
+  res <- .Call("_colSumByGroup", x, group)
20 20
   return(res)
21 21
 }
22 22
 
23
-#' @useDynLib celda colSumByGroupChange
23
+#' @useDynLib celda _colSumByGroupChange
24 24
 colSumByGroupChange <- function(x, px, group, pgroup, K) {
25 25
   group <- factor(group, levels=1:K)
26 26
   pgroup <- factor(pgroup, levels=1:K)    
27
-  res <- .Call("colSumByGroupChange", x, px, group, pgroup)
27
+  res <- .Call("_colSumByGroupChange", x, px, group, pgroup)
28 28
   return(res)
29 29
 }
30 30
 
Browse code

Fix to issues #237, #239, #251 (#253)

* Added new distance metrics to celda

* Add library(SummarizedExperiment) to tests

* rename diffExp to diffExpBetweenCellStates

* Add K-detemination fxn alongside pre-run object for output. Vignette modifications

* Vignette, modify

* New fxn: looks up transcriptional state of a gene

* fix lookup fxn

* new heatmap fxn, added R object for calcPerplexity result, update to vignette

* Minor formatting update for vignette

* Minor modification to vignette

* Vignette update. Finalized PBMC analysis. PBMC celda object updated for 2nd-pass run. renderProbability heatmap split to two fxns.

* fix to issues #241 and #242

* Fix to issue #237, #239, #251; Fix to #241 and #242 done on previous commit

* Fixed error test in testthat

* Vignette update

* Updating namespace namespace

Former-commit-id: 5ed75f329556d28e14f05781b91c8cea2f6199d7

ykoga07 authored on 04/06/2018 01:15:08 • Sean committed on 04/06/2018 01:15:08
Showing 1 changed files
... ...
@@ -1,11 +1,11 @@
1
-#' @useDynLib celda rowSumByGroup_
1
+#' @useDynLib celda rowSumByGroup
2 2
 rowSumByGroup <- function(x, group, L) {
3 3
   group <- factor(group, levels=1:L)
4 4
   res <- .Call("rowSumByGroup", x, group)
5 5
   return(res)
6 6
 }
7 7
 
8
-#' @useDynLib celda rowSumByGroupChange_
8
+#' @useDynLib celda rowSumByGroupChange
9 9
 rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10 10
   group <- factor(group, levels=1:L)
11 11
   pgroup <- factor(pgroup, levels=1:L)  
... ...
@@ -13,14 +13,14 @@ rowSumByGroupChange <- function(x, px, group, pgroup, L) {
13 13
   return(res)
14 14
 }
15 15
 
16
-#' @useDynLib celda colSumByGroup_
16
+#' @useDynLib celda colSumByGroup
17 17
 colSumByGroup <- function(x, group, K) {
18 18
   group <- factor(group, levels=1:K)
19 19
   res <- .Call("colSumByGroup", x, group)
20 20
   return(res)
21 21
 }
22 22
 
23
-#' @useDynLib celda colSumByGroupChange_
23
+#' @useDynLib celda colSumByGroupChange
24 24
 colSumByGroupChange <- function(x, px, group, pgroup, K) {
25 25
   group <- factor(group, levels=1:K)
26 26
   pgroup <- factor(pgroup, levels=1:K)    
Browse code

Optimized rowsum Functions (#249)

* Require class check on count matrix.

Require that all provided count matrices are checked to see if they're integer type, and if not, casting them to be that type.
Explicitly cast simulateCells() simulated count matrices to integer. Added unit tests to ensure this happens for this function.

* Updating documentation

* Fixing broken unit tests

* Moving dangling references to process.counts param

* Set integer storage.mode in processCounts()

* RcppEigen for fast matrix multiplication in celda_C EM

Use RcppEigen to do fast matrix multiplication in the newly implemented EM optimizations in celda_C.

* Fixed call to eigenMatMultInt. Added documentation.

* Rename rowsum functions. Documentation for eigenMatMultInt.

* Fixing loading of C++ function

* Adding fast implementation of rowSumsByGroup/colSumsByGroup.

* Removing .o and .dll files

* Ignore .o and .dll files

* Convert tests' simulated count matrices to integer.

* Regenerated test results.

* Fixing test data.


Former-commit-id: c6986abd6602f8b8f2bc7e762be655c942722103

Sean authored on 01/06/2018 15:45:08 • GitHub committed on 01/06/2018 15:45:08
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,30 @@
1
+#' @useDynLib celda rowSumByGroup_
2
+rowSumByGroup <- function(x, group, L) {
3
+  group <- factor(group, levels=1:L)
4
+  res <- .Call("rowSumByGroup", x, group)
5
+  return(res)
6
+}
7
+
8
+#' @useDynLib celda rowSumByGroupChange_
9
+rowSumByGroupChange <- function(x, px, group, pgroup, L) {
10
+  group <- factor(group, levels=1:L)
11
+  pgroup <- factor(pgroup, levels=1:L)  
12
+  res <- .Call("rowSumByGroupChange", x, px, group, pgroup)
13
+  return(res)
14
+}
15
+
16
+#' @useDynLib celda colSumByGroup_
17
+colSumByGroup <- function(x, group, K) {
18
+  group <- factor(group, levels=1:K)
19
+  res <- .Call("colSumByGroup", x, group)
20
+  return(res)
21
+}
22
+
23
+#' @useDynLib celda colSumByGroupChange_
24
+colSumByGroupChange <- function(x, px, group, pgroup, K) {
25
+  group <- factor(group, levels=1:K)
26
+  pgroup <- factor(pgroup, levels=1:K)    
27
+  res <- .Call("colSumByGroupChange", x, px, group, pgroup)
28
+  return(res)
29
+}
30
+