Skip to contents

Writes the gene by sample table as a tab-separated file, with the gene in the first column, optionally followed by the original gene IDs behind each row and the gene type from a GTF file, then one column per sample. A file name ending in .gz is compressed. The file is for sharing and for other tools; to continue in R, keep using the table itself.

Usage

rsem_write(x, file, ids = attr(x, "gene_ids", exact = TRUE), annotation = NULL)

Arguments

x

The gene by sample table.

file

Output path (.tsv or .tsv.gz).

ids

The attribute "gene_ids" of the table rsem_read() returned, attr(tpm, "gene_ids"): adds the column gene_id with the original IDs of each row, joined by ";" where several IDs were summed into one symbol. The other functions return new tables without this attribute, so take it from the table rsem_read() gave. By default the attribute of x is used when it is there.

annotation

Optional GTF file or data frame, as in rsem_biotype_profile(): adds the column gene_type.

Value

file, invisibly.

Examples

x <- data.frame(S1 = c(1.5, 2), S2 = c(3, 4), row.names = c("TP53", "GAPDH"))
f <- tempfile(fileext = ".tsv")
rsem_write(x, f)
#> rsem_write: 2 genes x 2 samples to /tmp/RtmpMQP6a1/file196977418b85.tsv (columns: gene, samples)
readLines(f)
#> [1] "gene\tS1\tS2" "TP53\t1.5\t3" "GAPDH\t2\t4"