File: pivot_wider_profile.Rd

package info (click to toggle)
r-bioc-decoupler 2.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,572 kB
  • sloc: makefile: 5
file content (103 lines) | stat: -rw-r--r-- 3,060 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils-profiles.R
\name{pivot_wider_profile}
\alias{pivot_wider_profile}
\title{Pivot a data frame to wider and convert it to matrix}
\usage{
pivot_wider_profile(
  data,
  id_cols,
  names_from,
  values_from,
  values_fill = NA,
  to_matrix = FALSE,
  to_sparse = FALSE,
  ...
)
}
\arguments{
\item{data}{A data frame to pivot.}

\item{id_cols}{<\code{\link[tidyr:tidyr_tidy_select]{tidy-select}}> A set of columns that
uniquely identifies each observation. Defaults to all columns in \code{data}
except for the columns specified in \code{names_from} and \code{values_from}.
Typically used when you have redundant variables, i.e. variables whose
values are perfectly correlated with existing variables.}

\item{names_from}{<\code{\link[tidyr:tidyr_tidy_select]{tidy-select}}> A pair of
arguments describing which column (or columns) to get the name of the
output column (\code{names_from}), and which column (or columns) to get the
cell values from (\code{values_from}).

If \code{values_from} contains multiple values, the value will be added to the
front of the output column.}

\item{values_from}{<\code{\link[tidyr:tidyr_tidy_select]{tidy-select}}> A pair of
arguments describing which column (or columns) to get the name of the
output column (\code{names_from}), and which column (or columns) to get the
cell values from (\code{values_from}).

If \code{values_from} contains multiple values, the value will be added to the
front of the output column.}

\item{values_fill}{Optionally, a (scalar) value that specifies what each
\code{value} should be filled in with when missing.

This can be a named list if you want to apply different fill values to
different value columns.}

\item{to_matrix}{Logical value indicating if the result should be a matrix.
Parameter is ignored in case \code{sparse} is \code{TRUE}.}

\item{to_sparse}{Logical value indicating whether the resulting matrix
should be sparse or not.}

\item{...}{Additional arguments passed on to methods.}
}
\value{
"widened" data; it is increasing the number of columns and
decreasing the number of rows.
}
\description{
Generates a kind of table where the rows come from \code{id_cols},
the columns from \code{names_from} and the values from \code{values_from}.
}
\details{
In the current state of the function, to ensure its operation,
the \code{id_cols} parameter is a single selector.
}
\examples{
\dontrun{
df <- tibble::tibble(
    tf = c("tf_1", "tf_1", "tf_2", "tf_2"),
    gene = c("gene_1", "gene_2", "gene_1", "gene_2"),
    mor = c(1, -1, 1, -1)
)

# Return a tibble
pivot_wider_profile(
    data = df,
    id_cols = tf,
    names_from = gene,
    values_from = mor
)

# Return a matrix
pivot_wider_profile(
    data = df,
    id_cols = tf,
    names_from = gene,
    values_from = mor,
    to_matrix = TRUE
)
# Return a sparse Matrix of class "dgCMatrix"
pivot_wider_profile(
    data = df,
    id_cols = tf,
    names_from = gene,
    values_from = mor,
    to_sparse = TRUE
)
}
}
\keyword{internal}