write_gct: Write matrix in GCT file format

View source: R/write_gct.R

write_gctR Documentation

Write matrix in GCT file format

Description

Write matrix in GCT file format

Usage

write_gct(matrix, file = stdout(), feat.name, feat.desc, na = "")

Arguments

matrix

A numeric matrix

file

Output file name. By default the file is written to standard output

feat.name

Character vector, optional. Feature names; if missing the row names are used as feature names. If given, feat.name must be of the same length as the row number of the input matrix.

feat.desc

Character vector, optional. Feature descriptions; if missing, empty strings will be used as descriptions.

na

Character string, how 'NA' values will be printed?

Details

Input matrix will be transformed into the GCT format. The transformed texts are printed on the standard output or in specified files.

If the input matrix has NULL as row names, and the feat.name option is left missing, a warning message will be print and the NAME column of the gct file will use integer indices starting from 1.

feat.desc specifies feature descriptions. Leaving is missing, or assigning it to NA or NULL will output a description column filled with empty strings.

Value

Texts printed in stdout() or in output file.

Note

From version 1.0-22, write_gct is able to handle zero-row matrix (see examples below)

Author(s)

Jitao David Zhang <jitao_david.zhang@roche.com>

See Also

read_gct_matrix to read matrix from GCT files.

Examples


tmpMatrix <- matrix(rnorm(15), nrow=3L, ncol=5L,
dimnames=list(LETTERS[1:3L], letters[1:5L]))

write_gct(tmpMatrix)
write_gct(tmpMatrix, file=tempfile())

## specify feature names
write_gct(tmpMatrix, feat.name=c("F1", "F2", "F3"))
write_gct(tmpMatrix, feat.name=c("F1", "F2", "F3"), feat.desc=NULL)
write_gct(tmpMatrix, feat.name=c("F1", "F2", "F3"), feat.desc=NA)

## specify feature names and descriptions
write_gct(tmpMatrix, feat.name=c("F1", "F2", "F3"), feat.desc=
c("Feature 1", "Feature 2", "Feature 3"))

## special case: 0-row matrix
write_gct(tmpMatrix[c(FALSE,FALSE,FALSE),,drop=FALSE])


ribiosIO documentation built on Feb. 20, 2026, 5:09 p.m.