Skip to contents

Unpivot column data from wide format to long format.

Usage

melt(object, ...)

# S4 method for Matrix
melt(
  object,
  colnames = c("rowname", "colname", "value"),
  min = -Inf,
  minMethod = c("absolute", "perRow"),
  trans = c("identity", "log2", "log10")
)

# S4 method for SummarizedExperiment
melt(
  object,
  assay = 1L,
  min = -Inf,
  minMethod = c("absolute", "perRow"),
  trans = c("identity", "log2", "log10")
)

Arguments

object

Object.

colnames

character(3). Column name mappings for melted data frame return.

min

numeric(1) or NULL. Minimum count threshold to apply. Filters using "greater than or equal to" logic internally. Note that this threshold gets applied prior to logarithmic transformation, when trans argument applies. Use -Inf or NULL to disable.

minMethod

character(1). Only applies when min argument is numeric. Uses match.arg().

  • absolute: Applies hard cutoff to counts column after the melt operation. This applies to all counts, not per feature.

  • perRow: Applies cutoff per row (i.e. gene). Internally, rowSums() values are checked against this cutoff threshold prior to the melt operation.

trans

character(1). Apply a log transformation (e.g. log2(x + 1L)) to the count matrix prior to melting, if desired. Use "identity" to return unmodified (default).

assay

vector(1). Assay name or index position.

...

Additional arguments.

Value

DataFrame.

Note

Updated 2023-10-27.

See also

Examples

data(RangedSummarizedExperiment, package = "AcidTest")

## SummarizedExperiment ====
object <- RangedSummarizedExperiment
dim(object)
#> [1] 500  12
x <- melt(object)
nrow(x)
#> [1] 6000
print(x)
#> DataFrame with 6000 rows and 6 columns
#>      rowname  colname value condition sampleName interestingGroups
#>        <Rle>    <Rle> <Rle>     <Rle>      <Rle>             <Rle>
#> 1    gene001 sample01    58         A   sample01                 A
#> 2    gene002 sample01    14         A   sample01                 A
#> 3    gene003 sample01    49         A   sample01                 A
#> 4    gene004 sample01     5         A   sample01                 A
#> 5    gene005 sample01    54         A   sample01                 A
#> ...      ...      ...   ...       ...        ...               ...
#> 5996 gene496 sample12    80         B   sample12                 B
#> 5997 gene497 sample12     0         B   sample12                 B
#> 5998 gene498 sample12     2         B   sample12                 B
#> 5999 gene499 sample12     8         B   sample12                 B
#> 6000 gene500 sample12    64         B   sample12                 B