TransposeAssay: Transpose an Assay (Data Frame)

Description Usage Arguments Details Value Examples

View source: R/utils_transpose_assay.R

Description

Transpose an object of class data.frame that contains assay measurements while preserving row (feature) and column (sample) names.

Usage

1
2
3
4
5
TransposeAssay(
  assay_df,
  omeNames = c("firstCol", "rowNames"),
  stringsAsFactors = FALSE
)

Arguments

assay_df

A data frame with numeric values to transpose

omeNames

Are the data feature names in the first column or in the row names of df? Defaults to the first column. If the feature names are in the row names, this function assumes that these names are accesible by the rownames function called on df.

stringsAsFactors

Should columns containing string information be coerced to factors? Defaults to FALSE.

Details

This function is designed to transpose "tall" assay data frames (where genes or proteins are the rows and patient or tumour samples are the columns). This function also transposes the row (feature) names to column names and the column (sample) names to row names. Notice that all rows and columns (other than the feature name column, as applicable) are numeric.

Recall that data frames require that all elements of a single column to have the same class. Therefore, sample IDs of a "tall" data frame must be stored as the column names rather than in the first row.

Value

The transposition of df, with row and column names preserved and reversed.

Examples

1
2
3
4
5
6
   x_mat <- matrix(rnorm(5000), ncol = 20, nrow = 250)
   rownames(x_mat) <- paste0("gene_", 1:250)
   colnames(x_mat) <- paste0("sample_", 1:20)
   x_df <- as.data.frame(x_mat, row.names = rownames(x_mat))

   TransposeAssay(x_df, omeNames = "rowNames")

pathwayPCA documentation built on Dec. 15, 2020, 6:14 p.m.