jj_match_matrices: match two matrices/data.frames by their row names/column...

View source: R/jj_match_matrices.R

jj_match_matricesR Documentation

match two matrices/data.frames by their row names/column names

Description

return the subset of two matrices that shares the same rownames, colnames or both.

Usage

jj_match_matrices(
  mat_a,
  mat_b,
  match_by = c("all", "columns", "rows")[1],
  print_only = FALSE,
  verbose = T
)

Arguments

mat_a

matrix 1

mat_b

matrix 2

match_by

match by columns, rows or all

print_only

only print out whether rownames or colnames are identical between two matrices

verbose

rownames to set

Value

Returns a list with the matched features/samples in the same order

Examples

matrix1 = matrix(1:80, nrow = 8, dimnames = list(paste0('gene_',1:8), paste0('cell_', 1:10)))
matrix2 = matrix(1:50, nrow = 5, dimnames = list(paste0('gene_',c(1,4,8,2,3)), paste0('cell_', c(2:5, 8:13))))
jj_match_matrices(matrix1, matrix2, print_only = T)
jj_match_matrices(matrix1, matrix2)

mathosi/jj documentation built on Feb. 25, 2024, 2:29 p.m.