mutate_matrix {matrixset}R Documentation

Create/modify/delete matrices from a matrixset object

Description

Applies functions that takes matrices as input and return similar matrices. The definition of similar is that the new matrix has the same dimension and dimnames as .ms.

If the returned matrix is assigned to a new matrix, this matrix is added to the matrixset object. If it is assigned to an already existing matrix, it overwrites the matrix of the same name.

Setting a matrix value to NULL will not delete the matrix, but will create an empty slot (NULL) for the matrix.

To delete a matrix, use the function remove_matrix(). See examples below.

Note that matrices are created sequentially and can be used by other name-value pairs. There is an example that showcases this.

Usage

mutate_matrix(.ms, ...)

Arguments

.ms

A matrixset object.

...

Name-value pairs, ala dplyr's dplyr::mutate(). The value can be one of:

  • a matrix, with same dimension and dimnames as .ms.

  • NULL, which will turn the matrix as an empty placeholder.

  • remove_matrix(), to remove the matrix

Value

A matrixset with updated matrices.

Examples

# Notice how FC can be used as soon as created
ms <- mutate_matrix(student_results,
                    FC = remedial/failure,
                    foo = NULL,
                    logFC = log2(FC),
                    FC = remove_matrix())
# this is NULL
matrix_elm(ms, "foo")

# running this would return an error, since FC was deleted
# matrix_elm(ms, "FC")


[Package matrixset version 0.3.0 Index]