Skip to contents

This function exports the data from a Seurat object into a 10X Genomics-style format. The output includes files for the expression matrix, feature (gene) information, barcodes, metadata, UMAP (or other reductions), and variable features. These files are written in a compressed format where applicable.

Usage

make3file(seu, assay = "RNA", dir, get_reductions = TRUE)

Arguments

seu

A Seurat object containing the data to be exported.

assay

A character string indicating which assay to use from the Seurat object. Default is "RNA".

dir

A character string specifying the directory where the output files will be saved. The directory must already exist.

get_reductions

Logical, whether to include cell embeddings from reductions (e.g., UMAP, PCA, etc.) in the output. Default is TRUE.

Value

The function does not return a value. It writes several files as a side effect.

Details

The function creates several files in a subdirectory called 3file within the specified directory:

  • matrix.mtx.gz: A compressed MatrixMarket file containing the assay data (expression matrix).

  • features.tsv.gz: A tab-separated file with feature (gene) information, including gene names.

  • barcodes.tsv.gz: A tab-separated file with cell barcodes.

  • meta.csv: A CSV file containing metadata from the Seurat object.

  • <reduction>_reduction.tsv.gz: A compressed file with cell embeddings for each reduction (e.g., UMAP, PCA), if get_reductions is set to TRUE.

  • variablefeatures.tsv.gz: A compressed file listing the variable features.

If reductions (like UMAP or PCA) are present in the Seurat object and get_reductions is TRUE, the cell embeddings from each reduction will be written to separate files in the format <reduction>_reduction.tsv.gz. If the UMAP or PCA embeddings are not found in the Seurat object and get_reductions is set to TRUE, the function will issue a warning but will still generate the other files. The function will create the 3file subdirectory within the specified directory if it doesn't exist.

Examples

if (FALSE) {
library(Seurat)
seu <- CreateSeuratObject(counts = matrix(rnorm(100), 10, 10))
make3file(seu, assay = "RNA", dir = "output_directory")

# Export Seurat object with reductions
make3file(seu, assay = "RNA", dir = "output_directory", get_reductions = TRUE)

# Export Seurat object without reductions
make3file(seu, assay = "RNA", dir = "output_directory", get_reductions = FALSE)
}