This function reads a matrix, barcodes, and features from a specified directory and returns the matrix with appropriate row and column names.

read_matrix_from_folder(dir)

Arguments

dir

Character. The directory containing the matrix, barcodes, and features files.

Value

A sparse matrix with barcodes as column names and features as row names.

Details

The specified directory must contain the following files:

  • Matrix file: A file with the extension .mtx.gz or .mtx. This file contains the count matrix in Matrix Market format.

  • Barcodes file: A file with the name barcodes.tsv.gz or barcodes.tsv. This file contains the barcodes for the columns of the matrix.

  • Features file: A file with the name features.tsv.gz or features.tsv. This file contains the features (e.g., gene names) for the rows of the matrix.

The function will search for these files in the specified directory and read them using appropriate functions. The matrix will be returned with barcodes as column names and features as row names.

Examples


if (FALSE) { # \dontrun{
  matrix_dir <- "path/to/matrix/folder"
  matrix <- read_matrix_from_folder(matrix_dir)
  print(matrix)
} # }