This makes sparseMatrixStats compatible with v0.60 of matrixStats
In this commit
* I introduce a set of function called `set_result_names()`
that take the internally computed result and add correct names if needed
* Add colnames to the matrices of the unit tests
* Update the documentation to reflect the changed method signatures
... | ... |
@@ -6,9 +6,9 @@ |
6 | 6 |
\title{Calculates the minimum and maximum for each row (column) of a matrix-like |
7 | 7 |
object} |
8 | 8 |
\usage{ |
9 |
-\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE) |
|
9 |
+\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, useNames = NA) |
|
10 | 10 |
|
11 |
-\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE) |
|
11 |
+\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, useNames = NA) |
|
12 | 12 |
} |
13 | 13 |
\arguments{ |
14 | 14 |
\item{x}{An NxK matrix-like object.} |
... | ... |
@@ -23,6 +23,8 @@ done.} |
23 | 23 |
|
24 | 24 |
\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link{NA}}s |
25 | 25 |
are excluded first, otherwise not.} |
26 |
+ |
|
27 |
+\item{useNames}{If \code{\link{NA}}, the default behavior of the function about naming support is remained. If \code{\link{FALSE}}, no naming support is done. Else if \code{\link{TRUE}}, names attributes of result are set.} |
|
26 | 28 |
} |
27 | 29 |
\value{ |
28 | 30 |
a \code{\link{numeric}} \code{Nx2} (\code{Kx2}) |
... | ... |
@@ -36,8 +36,8 @@ object. |
36 | 36 |
\details{ |
37 | 37 |
The S4 methods for \code{x} of type \code{\link{matrix}}, |
38 | 38 |
\code{\link{array}}, or \code{\link{numeric}} call |
39 |
-\code{matrixStats::\link[matrixStats]{rowRanges}} |
|
40 |
-/ \code{matrixStats::\link[matrixStats:rowRanges]{colRanges}}. |
|
39 |
+\code{matrixStats::rowRanges} |
|
40 |
+/ \code{matrixStats::colRanges}. |
|
41 | 41 |
} |
42 | 42 |
\examples{ |
43 | 43 |
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) |
See https://github.com/Bioconductor/MatrixGenerics/issues/11
for more information
... | ... |
@@ -13,19 +13,19 @@ object} |
13 | 13 |
\arguments{ |
14 | 14 |
\item{x}{An NxK matrix-like object.} |
15 | 15 |
|
16 |
-\item{rows}{A \code{\link[base]{vector}} indicating the subset of rows |
|
17 |
-(and/or columns) to operate over. If \code{\link[base]{NULL}}, no |
|
18 |
-subsetting is done.} |
|
16 |
+\item{rows}{A \code{\link{vector}} indicating the subset of rows |
|
17 |
+(and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is |
|
18 |
+done.} |
|
19 | 19 |
|
20 |
-\item{cols}{A \code{\link[base]{vector}} indicating the subset of rows |
|
21 |
-(and/or columns) to operate over. If \code{\link[base]{NULL}}, no |
|
22 |
-subsetting is done.} |
|
20 |
+\item{cols}{A \code{\link{vector}} indicating the subset of rows |
|
21 |
+(and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is |
|
22 |
+done.} |
|
23 | 23 |
|
24 |
-\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s |
|
24 |
+\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link{NA}}s |
|
25 | 25 |
are excluded first, otherwise not.} |
26 | 26 |
} |
27 | 27 |
\value{ |
28 |
-a \code{\link[base]{numeric}} \code{Nx2} (\code{Kx2}) |
|
28 |
+a \code{\link{numeric}} \code{Nx2} (\code{Kx2}) |
|
29 | 29 |
\code{\link{matrix}}, where N (K) is the number of rows (columns) for |
30 | 30 |
which the ranges are calculated. |
31 | 31 |
} |
... | ... |
@@ -34,10 +34,10 @@ Calculates the minimum and maximum for each row (column) of a matrix-like |
34 | 34 |
object. |
35 | 35 |
} |
36 | 36 |
\details{ |
37 |
-The S4 methods for \code{x} of type \code{\link[base]{matrix}}, |
|
38 |
-\code{\link[base]{array}}, or \code{\link[base]{numeric}} call |
|
37 |
+The S4 methods for \code{x} of type \code{\link{matrix}}, |
|
38 |
+\code{\link{array}}, or \code{\link{numeric}} call |
|
39 | 39 |
\code{matrixStats::\link[matrixStats]{rowRanges}} |
40 |
-/ \code{matrixStats::\link[matrixStats]{colRanges}}. |
|
40 |
+/ \code{matrixStats::\link[matrixStats:rowRanges]{colRanges}}. |
|
41 | 41 |
} |
42 | 42 |
\examples{ |
43 | 43 |
mat <- matrix(rnorm(15), nrow = 5, ncol = 3) |
... | ... |
@@ -53,10 +53,10 @@ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) |
53 | 53 |
\seealso{ |
54 | 54 |
\itemize{ |
55 | 55 |
\item \code{matrixStats::\link[matrixStats]{rowRanges}()} and |
56 |
-\code{matrixStats::\link[matrixStats]{colRanges}()} which are used when |
|
57 |
-the input is a \code{matrix} or \code{numeric} vector. |
|
56 |
+\code{matrixStats::\link[matrixStats:rowRanges]{colRanges}()} which are |
|
57 |
+used when the input is a \code{matrix} or \code{numeric} vector. |
|
58 | 58 |
\item For max estimates, see \code{\link[MatrixGenerics]{rowMaxs}()}. |
59 | 59 |
\item For min estimates, see \code{\link[MatrixGenerics]{rowMins}()}. |
60 |
-\item \code{base::\link[base]{range}()}. |
|
60 |
+\item \code{base::\link{range}()}. |
|
61 | 61 |
} |
62 | 62 |
} |
... | ... |
@@ -6,9 +6,9 @@ |
6 | 6 |
\title{Calculates the minimum and maximum for each row (column) of a matrix-like |
7 | 7 |
object} |
8 | 8 |
\usage{ |
9 |
-\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, ...) |
|
9 |
+\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE) |
|
10 | 10 |
|
11 |
-\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, ...) |
|
11 |
+\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE) |
|
12 | 12 |
} |
13 | 13 |
\arguments{ |
14 | 14 |
\item{x}{An NxK matrix-like object.} |
... | ... |
@@ -23,8 +23,6 @@ subsetting is done.} |
23 | 23 |
|
24 | 24 |
\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s |
25 | 25 |
are excluded first, otherwise not.} |
26 |
- |
|
27 |
-\item{...}{Additional arguments passed to specific methods.} |
|
28 | 26 |
} |
29 | 27 |
\value{ |
30 | 28 |
a \code{\link[base]{numeric}} \code{Nx2} (\code{Kx2}) |
... | ... |
@@ -3,7 +3,8 @@ |
3 | 3 |
\name{colRanges,dgCMatrix-method} |
4 | 4 |
\alias{colRanges,dgCMatrix-method} |
5 | 5 |
\alias{rowRanges,dgCMatrix-method} |
6 |
-\title{Calculates the minimum and maximum for each row (column) of a matrix-like object} |
|
6 |
+\title{Calculates the minimum and maximum for each row (column) of a matrix-like |
|
7 |
+object} |
|
7 | 8 |
\usage{ |
8 | 9 |
\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, ...) |
9 | 10 |
|
... | ... |
@@ -12,11 +13,13 @@ |
12 | 13 |
\arguments{ |
13 | 14 |
\item{x}{An NxK matrix-like object.} |
14 | 15 |
|
15 |
-\item{rows}{A \code{\link[base]{vector}} indicating the subset (and/or |
|
16 |
-columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} |
|
16 |
+\item{rows}{A \code{\link[base]{vector}} indicating the subset of rows |
|
17 |
+(and/or columns) to operate over. If \code{\link[base]{NULL}}, no |
|
18 |
+subsetting is done.} |
|
17 | 19 |
|
18 |
-\item{cols}{A \code{\link[base]{vector}} indicating the subset (and/or |
|
19 |
-columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} |
|
20 |
+\item{cols}{A \code{\link[base]{vector}} indicating the subset of rows |
|
21 |
+(and/or columns) to operate over. If \code{\link[base]{NULL}}, no |
|
22 |
+subsetting is done.} |
|
20 | 23 |
|
21 | 24 |
\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s |
22 | 25 |
are excluded first, otherwise not.} |
... | ... |
@@ -24,15 +27,18 @@ are excluded first, otherwise not.} |
24 | 27 |
\item{...}{Additional arguments passed to specific methods.} |
25 | 28 |
} |
26 | 29 |
\value{ |
27 |
-a \code{\link[base]{numeric}} \code{Nx2} (\code{Kx2}) \code{\link{matrix}}, where |
|
28 |
-N (K) is the number of rows (columns) for which the ranges are calculated. |
|
30 |
+a \code{\link[base]{numeric}} \code{Nx2} (\code{Kx2}) |
|
31 |
+\code{\link{matrix}}, where N (K) is the number of rows (columns) for |
|
32 |
+which the ranges are calculated. |
|
29 | 33 |
} |
30 | 34 |
\description{ |
31 |
-Calculates the minimum and maximum for each row (column) of a matrix-like object. |
|
35 |
+Calculates the minimum and maximum for each row (column) of a matrix-like |
|
36 |
+object. |
|
32 | 37 |
} |
33 | 38 |
\details{ |
34 |
-The S4 methods for \code{x} of type \code{\link[base]{matrix}} or |
|
35 |
-\code{\link[base]{numeric}} call \code{matrixStats::\link[matrixStats]{rowRanges}} |
|
39 |
+The S4 methods for \code{x} of type \code{\link[base]{matrix}}, |
|
40 |
+\code{\link[base]{array}}, or \code{\link[base]{numeric}} call |
|
41 |
+\code{matrixStats::\link[matrixStats]{rowRanges}} |
|
36 | 42 |
/ \code{matrixStats::\link[matrixStats]{colRanges}}. |
37 | 43 |
} |
38 | 44 |
\examples{ |
... | ... |
@@ -53,6 +59,6 @@ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) |
53 | 59 |
the input is a \code{matrix} or \code{numeric} vector. |
54 | 60 |
\item For max estimates, see \code{\link[MatrixGenerics]{rowMaxs}()}. |
55 | 61 |
\item For min estimates, see \code{\link[MatrixGenerics]{rowMins}()}. |
56 |
-\item \link{range} |
|
62 |
+\item \code{base::\link[base]{range}()}. |
|
57 | 63 |
} |
58 | 64 |
} |
... | ... |
@@ -1,16 +1,13 @@ |
1 | 1 |
% Generated by roxygen2: do not edit by hand |
2 | 2 |
% Please edit documentation in R/methods.R, R/methods_row.R |
3 |
-\docType{methods} |
|
4 | 3 |
\name{colRanges,dgCMatrix-method} |
5 | 4 |
\alias{colRanges,dgCMatrix-method} |
6 | 5 |
\alias{rowRanges,dgCMatrix-method} |
7 |
-\title{Calculates the mininum and maximum for each row (column) of a matrix-like object} |
|
6 |
+\title{Calculates the minimum and maximum for each row (column) of a matrix-like object} |
|
8 | 7 |
\usage{ |
9 |
-\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, |
|
10 |
- na.rm = FALSE, ...) |
|
8 |
+\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, ...) |
|
11 | 9 |
|
12 |
-\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, |
|
13 |
- na.rm = FALSE, ...) |
|
10 |
+\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, ...) |
|
14 | 11 |
} |
15 | 12 |
\arguments{ |
16 | 13 |
\item{x}{An NxK matrix-like object.} |
... | ... |
@@ -28,10 +25,10 @@ are excluded first, otherwise not.} |
28 | 25 |
} |
29 | 26 |
\value{ |
30 | 27 |
a \code{\link[base]{numeric}} \code{Nx2} (\code{Kx2}) \code{\link{matrix}}, where |
31 |
- N (K) is the number of rows (columns) for which the ranges are calculated. |
|
28 |
+N (K) is the number of rows (columns) for which the ranges are calculated. |
|
32 | 29 |
} |
33 | 30 |
\description{ |
34 |
-Calculates the mininum and maximum for each row (column) of a matrix-like object. |
|
31 |
+Calculates the minimum and maximum for each row (column) of a matrix-like object. |
|
35 | 32 |
} |
36 | 33 |
\details{ |
37 | 34 |
The S4 methods for \code{x} of type \code{\link[base]{matrix}} or |
... | ... |
@@ -52,9 +49,10 @@ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) |
52 | 49 |
\seealso{ |
53 | 50 |
\itemize{ |
54 | 51 |
\item \code{matrixStats::\link[matrixStats]{rowRanges}()} and |
55 |
- \code{matrixStats::\link[matrixStats]{colRanges}()} which are used when |
|
56 |
- the input is a \code{matrix} or \code{numeric} vector. |
|
57 |
-\item For max estimates, see \code{\link{rowMaxs}()}. |
|
58 |
-\item For min estimates, see \code{\link{rowMins}()}. |
|
52 |
+\code{matrixStats::\link[matrixStats]{colRanges}()} which are used when |
|
53 |
+the input is a \code{matrix} or \code{numeric} vector. |
|
54 |
+\item For max estimates, see \code{\link[MatrixGenerics]{rowMaxs}()}. |
|
55 |
+\item For min estimates, see \code{\link[MatrixGenerics]{rowMins}()}. |
|
56 |
+\item \link{range} |
|
59 | 57 |
} |
60 | 58 |
} |
- col/rowMaxs
- col/rowMeans2
- col/rowMedians
- col/rowMins
- col/rowRanges
- col/rowSds
- col/rowVars
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,60 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/methods.R, R/methods_row.R |
|
3 |
+\docType{methods} |
|
4 |
+\name{colRanges,dgCMatrix-method} |
|
5 |
+\alias{colRanges,dgCMatrix-method} |
|
6 |
+\alias{rowRanges,dgCMatrix-method} |
|
7 |
+\title{Calculates the mininum and maximum for each row (column) of a matrix-like object} |
|
8 |
+\usage{ |
|
9 |
+\S4method{colRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, |
|
10 |
+ na.rm = FALSE, ...) |
|
11 |
+ |
|
12 |
+\S4method{rowRanges}{dgCMatrix}(x, rows = NULL, cols = NULL, |
|
13 |
+ na.rm = FALSE, ...) |
|
14 |
+} |
|
15 |
+\arguments{ |
|
16 |
+\item{x}{An NxK matrix-like object.} |
|
17 |
+ |
|
18 |
+\item{rows}{A \code{\link[base]{vector}} indicating the subset (and/or |
|
19 |
+columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} |
|
20 |
+ |
|
21 |
+\item{cols}{A \code{\link[base]{vector}} indicating the subset (and/or |
|
22 |
+columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} |
|
23 |
+ |
|
24 |
+\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s |
|
25 |
+are excluded first, otherwise not.} |
|
26 |
+ |
|
27 |
+\item{...}{Additional arguments passed to specific methods.} |
|
28 |
+} |
|
29 |
+\value{ |
|
30 |
+a \code{\link[base]{numeric}} \code{Nx2} (\code{Kx2}) \code{\link{matrix}}, where |
|
31 |
+ N (K) is the number of rows (columns) for which the ranges are calculated. |
|
32 |
+} |
|
33 |
+\description{ |
|
34 |
+Calculates the mininum and maximum for each row (column) of a matrix-like object. |
|
35 |
+} |
|
36 |
+\details{ |
|
37 |
+The S4 methods for \code{x} of type \code{\link[base]{matrix}} or |
|
38 |
+\code{\link[base]{numeric}} call \code{matrixStats::\link[matrixStats]{rowRanges}} |
|
39 |
+/ \code{matrixStats::\link[matrixStats]{colRanges}}. |
|
40 |
+} |
|
41 |
+\examples{ |
|
42 |
+mat <- matrix(rnorm(15), nrow = 5, ncol = 3) |
|
43 |
+ mat[2, 1] <- NA |
|
44 |
+ mat[3, 3] <- Inf |
|
45 |
+ mat[4, 1] <- 0 |
|
46 |
+ |
|
47 |
+ print(mat) |
|
48 |
+ |
|
49 |
+ rowRanges(mat) |
|
50 |
+ colRanges(mat) |
|
51 |
+} |
|
52 |
+\seealso{ |
|
53 |
+\itemize{ |
|
54 |
+\item \code{matrixStats::\link[matrixStats]{rowRanges}()} and |
|
55 |
+ \code{matrixStats::\link[matrixStats]{colRanges}()} which are used when |
|
56 |
+ the input is a \code{matrix} or \code{numeric} vector. |
|
57 |
+\item For max estimates, see \code{\link{rowMaxs}()}. |
|
58 |
+\item For min estimates, see \code{\link{rowMins}()}. |
|
59 |
+} |
|
60 |
+} |