Unpivot column data from wide format to long format.
Arguments
- object
Object.
- assay
vector(1)
. Assay name or index position.- min
numeric(1)
orNULL
. Minimum count threshold to apply. Filters using "greater than or equal to" logic internally. Note that this threshold gets applied prior to logarithmic transformation, whentrans
argument applies. Use-Inf
orNULL
to disable.- minMethod
character(1)
. Only applies whenmin
argument is numeric. Usesmatch.arg()
.absolute
: Applies hard cutoff tocounts
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).- ...
Additional arguments.
See also
https://seananderson.ca/2013/10/19/reshape/
reshape2::melt
(deprecated).Python
pandas.melt
.
Examples
data(SingleCellExperiment_splatter, package = "AcidTest")
## SingleCellExperiment ====
object <- SingleCellExperiment_splatter
dim(object)
#> [1] 100 400
df <- melt(object)
nrow(df)
#> [1] 40000
print(df)
#> DataFrame with 40000 rows and 6 columns
#> rowname colname value sampleId sampleName interestingGroups
#> <Rle> <Rle> <Rle> <Rle> <Rle> <Rle>
#> 1 gene001 cell001 172 sample3 sample3 sample3
#> 2 gene002 cell001 1377 sample3 sample3 sample3
#> 3 gene003 cell001 29 sample3 sample3 sample3
#> 4 gene004 cell001 3 sample3 sample3 sample3
#> 5 gene005 cell001 376 sample3 sample3 sample3
#> ... ... ... ... ... ... ...
#> 39996 gene096 cell400 57 sample2 sample2 sample2
#> 39997 gene097 cell400 198 sample2 sample2 sample2
#> 39998 gene098 cell400 9 sample2 sample2 sample2
#> 39999 gene099 cell400 4724 sample2 sample2 sample2
#> 40000 gene100 cell400 1185 sample2 sample2 sample2