# Combine sparse matrices.

Source: `R/dtu_analysis.R`
`combine_to_matrix.Rd`

Combine list of sparse count matrices. Presumably coming from `import_counts()` or `import_dge_counts()` in conjunction with single-cell data.

    combine_to_matrix(
      tx_list,
      cell_extensions = NULL,
      cell_extension_side = "append",
      seurat_obj = NULL,
      tx2gene = NULL,
      assay_name = "dtutx"
    )

## Arguments

tx_list | List of sparse count matrices, as returned by `import_counts()` or `import_dge_counts()` for single-cell data.
cell_extensions | Optional vector of cellname extensions that are added to the cellnames of the samples. The original cellnames and the extension are separated by an underscore '_'. Defaults to an increasing integer per sample.
cell_extension_side | Define to which side of the barcode the cell extensions shall be added ('append' or 'prepend').
seurat_obj | Optional seurat object, where the combined matrix is added as an assay. This has the advantage, that the cells are matched and subsetted if necessary. Currently only Seurat 3 objects are supported.
tx2gene | Optional tx2gene or metadata data frame, can only be used in conjunction with a seurat object. Metadata is added as feature-level meta data to the created assay. The first column of the data frame must contain transcript names/ids. The same transcript names/ids as in the `tx_list` objects must be used.
assay_name | If the combined matrix should be added to an existing Seurat object, the name of the assay can be specified here.

## Value

Either a combined sparse count matrix or a seurat object which the combined sparse count matrix as an assay.

## Details

This function adds a cellname extension if necessary. Can optionally add the combined matrix to a existing Seurat object (keeping the cellname extension of the object and matching the cells). Also removes overall non expressed features.

## See also

Other DTUrtle DTU: `import_counts()`, `posthoc_and_stager()`, `priming_bias_detection_probability()`, `run_drimseq()`