const-ae / const-ae/sparseMatrixStats

`row/colVars()` and `row/colSds()` methods for xgCMatrix objects silently ignore the supplied `center`

Abierto
#13 5 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
R
Estrellas
55
Forks
3
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

See for example the definition of the `rowVars()` method:
```
library(sparseMatrixStats)

selectMethod("rowVars", "xgCMatrix")
# Method Definition:
#
# function (x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL, ...)
# {
# .local <- function (x, rows = NULL, cols = NULL, na.rm = FALSE)
# {
# if (!is.null(rows)) {
# x <- x[rows, , drop = FALSE]
# }
# if (!is.null(cols)) {
# x <- x[, cols, drop = FALSE]
# }
# dgCMatrix_rowVars(x, na_rm = na.rm)
# }
# .local(x, rows, cols, na.rm, ...)
# }
#
#
#
# Signatures:
# x
# target "xgCMatrix"
# defined "xgCMatrix"
```

Here is a concrete example using a dgCMatrix object:
```
library(Matrix)
i <- 1:5
j <- 2:6
m0 <- sparseMatrix(i, j, x=10*i+j, dims=c(5, 7)) # dgCMatrix object
```

`center` not supplied:
```
matrixStats::rowVars(as.matrix(m0))
# [1] 20.57143 75.57143 165.14286 289.28571 448.00000
rowVars(m0)
# [1] 20.57143 75.57143 165.14286 289.28571 448.00000
```

`center` supplied:
```
matrixStats::rowVars(as.matrix(m0), center=0)
# [1] 24.00000 88.16667 192.66667 337.50000 522.66667
rowVars(m0, center=0) # 'center' is ignored!
# [1] 20.57143 75.57143 165.14286 289.28571 448.00000
```

Thanks,
H.

**sessionInfo():**
```
R Under development (unstable) (2020-10-28 r79382)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.7 LTS

Matrix products: default
BLAS: /home/hpages/R/R-4.1.r79382/lib/libRblas.so
LAPACK: /home/hpages/R/R-4.1.r79382/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] Matrix_1.2-18 sparseMatrixStats_1.3.0 MatrixGenerics_1.3.0
[4] matrixStats_0.57.0

loaded via a namespace (and not attached):
[1] compiler_4.1.0 Rcpp_1.0.5 grid_4.1.0 lattice_0.20-41
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Empieza inspeccionando los métodos de xgCMatrix para rowVars(), colVars(), rowSds() y colSds(), utilizando la salida proporcionada de selectMethod("rowVars", "xgCMatrix") y el ejemplo de dgCMatrix para reproducir el comportamiento. Confirma que proporcionar center cambia los resultados como lo hace matrixStats::rowVars(); el issue está terminado cuando los cuatro métodos respetan de forma coherente el center proporcionado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
r
Área
data
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.