File: colAvgsPerRowSet-xgCMatrix-method.Rd

package info (click to toggle)
r-bioc-sparsematrixstats 1.2.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,052 kB
  • sloc: cpp: 1,332; makefile: 2
file content (91 lines) | stat: -rw-r--r-- 2,725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/methods.R, R/methods_row.R
\name{colAvgsPerRowSet,xgCMatrix-method}
\alias{colAvgsPerRowSet,xgCMatrix-method}
\alias{colAvgsPerRowSet}
\alias{rowAvgsPerColSet,xgCMatrix-method}
\title{Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows)}
\usage{
\S4method{colAvgsPerRowSet}{xgCMatrix}(
  X,
  W = NULL,
  cols = NULL,
  S,
  FUN = colMeans2,
  ...,
  na.rm = NA,
  tFUN = FALSE
)

\S4method{rowAvgsPerColSet}{xgCMatrix}(
  X,
  W = NULL,
  rows = NULL,
  S,
  FUN = rowMeans2,
  ...,
  na.rm = NA,
  tFUN = FALSE
)
}
\arguments{
\item{X}{An \code{NxM} matrix-like object.}

\item{W}{An optional numeric \code{NxM} matrix of weights.}

\item{cols}{A \code{\link{vector}} indicating the subset (and/or
columns) to operate over. If \code{\link{NULL}}, no subsetting is
done.}

\item{S}{An \link{integer} \code{KxJ} matrix that specifying the \code{J} subsets. Each
column hold \code{K} column (row) indices for the corresponding subset. The
range of values is [1, M] ([1,N]).}

\item{FUN}{A row-by-row (column-by-column) summary statistic function. It is
applied to to each column (row) subset of \code{X} that is specified by \code{S}.}

\item{...}{Additional arguments passed to \code{FUN}.}

\item{na.rm}{(logical) Argument passed to \code{FUN()} as \code{na.rm = na.rm}.
If \code{NA} (default), then \code{na.rm = TRUE} is used if \code{X} or \code{S} holds missing values,
otherwise \code{na.rm = FALSE}.}

\item{tFUN}{If \code{TRUE}, \code{X} is transposed before it is passed to \code{FUN}.}

\item{rows}{A \code{\link{vector}} indicating the subset (and/or
columns) to operate over. If \code{\link{NULL}}, no subsetting is
done.}
}
\value{
Returns a numeric \code{JxN} (\code{MxJ}) matrix.
}
\description{
Calculates for each row (column) a summary statistic for equally sized subsets of columns (rows)
}
\details{
**Note**: the handling of missing parameters differs from
  [matrixStats::colAvgsPerRowSet()]. The `matrixStats` version
  always removes `NA`'s if there are any in the data. This method
  however does whatever is passed in the `...` parameter.
}
\examples{
mat <- matrix(rnorm(20), nrow = 5, ncol = 4)
  mat[2, 1] <- NA
  mat[3, 3] <- Inf
  mat[4, 1] <- 0
  
  print(mat)
  
  S <- matrix(1:ncol(mat), ncol = 2)
  print(S)
  
  rowAvgsPerColSet(mat, S = S, FUN = rowMeans)
  rowAvgsPerColSet(mat, S = S, FUN = rowVars)
}
\seealso{
\itemize{
\item \code{matrixStats::\link[matrixStats:rowAvgsPerColSet]{rowAvgsPerColSet}()}
and \code{matrixStats::\link[matrixStats:rowAvgsPerColSet]{colAvgsPerRowSet}()}
which are used when the input is a \code{matrix} or \code{numeric} vector.
}
}