I have 3 files (barcodes.tsv, features.tsv and matrix.mtx) which I want to make them into one matrix. rows will be features columns will be barcodes and the counts (matrix) being the data points.
How can I do this on R?
1 answer
Read the mtx file with readMM() from the Matrix package. Then load the other two with something like read.delim(). From there it's standard R operations, so use colnames() to assign the content of the barcode file as colnames and rownames() to assign the gene information from the feature file as rownames. You might consider using container formats such as a Seurat objects or SingleCellExperiments to store the data as this allows to keep everything in sync. If this is single-cell data you might follow a good guide such as https://bioconductor.org/books/release/OSCA/
Log in to answer this question.