Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VISOR
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AG Seifert
VISOR
Commits
d941aa15
Verified
Commit
d941aa15
authored
9 months ago
by
Gärber, Florian
Browse files
Options
Downloads
Patches
Plain Diff
feat(ChemoSpec): Make groups parameter optional
parent
294efb2d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/to_ChemoSpec.R
+13
-6
13 additions, 6 deletions
R/to_ChemoSpec.R
with
13 additions
and
6 deletions
R/to_ChemoSpec.R
+
13
−
6
View file @
d941aa15
#' *️⃣ {ChemoSpec}
#' *️⃣ {ChemoSpec}
#'
#'
#' @param data Numeric matrix with samples in rows and frequencies in cols.
#' @param data Numeric matrix with samples in rows and frequencies in cols.
#' @param groups Factor with sample class assignments.
#' @param groups Factor with sample class assignments or single integer or string value.
#' Length must match `nrow()` of `data`.
#' Length of factor must match `nrow(data)`.
#' A single value is treated as setting the same group for all samples.
#' **Defaults to** `"{missing group}"`
#' @param freq Numeric vector with unique frequencies.
#' @param freq Numeric vector with unique frequencies.
#' Length must match `ncol()` of `data`.
#' Length must match `ncol()` of `data`.
#' **Defaults to** `colnames()` of `data` cast `as.numeric()`.
#' **Defaults to** `colnames()` of `data` cast `as.numeric()`.
...
@@ -33,7 +35,7 @@
...
@@ -33,7 +35,7 @@
#' @keywords to_ChemoSpec
#' @keywords to_ChemoSpec
to_ChemoSpec
<-
function
(
to_ChemoSpec
<-
function
(
data
,
data
,
groups
,
groups
=
"{missing group}"
,
freq
=
base
::
colnames
(
data
)
|>
base
::
as.numeric
(),
freq
=
base
::
colnames
(
data
)
|>
base
::
as.numeric
(),
names
=
base
::
rownames
(
data
),
names
=
base
::
rownames
(
data
),
desc
=
"{missing description}"
,
desc
=
"{missing description}"
,
...
@@ -57,6 +59,11 @@ to_ChemoSpec <- function(
...
@@ -57,6 +59,11 @@ to_ChemoSpec <- function(
names
,
names
,
any.missing
=
FALSE
,
unique
=
TRUE
,
len
=
base
::
nrow
(
data
)
any.missing
=
FALSE
,
unique
=
TRUE
,
len
=
base
::
nrow
(
data
)
)
)
if
(
checkmate
::
test_string
(
groups
)
||
checkmate
::
test_int
(
groups
))
{
groups
<-
base
::
as.factor
(
base
::
rep
(
groups
,
base
::
nrow
(
data
)))
}
checkmate
::
assert_factor
(
checkmate
::
assert_factor
(
groups
,
groups
,
len
=
base
::
nrow
(
data
),
empty.levels.ok
=
FALSE
,
any.missing
=
FALSE
,
min.levels
=
1
len
=
base
::
nrow
(
data
),
empty.levels.ok
=
FALSE
,
any.missing
=
FALSE
,
min.levels
=
1
...
@@ -148,7 +155,7 @@ to_ChemoSpec <- function(
...
@@ -148,7 +155,7 @@ to_ChemoSpec <- function(
#' @seealso `to_ChemoSpec()`
#' @seealso `to_ChemoSpec()`
matrix_to_ChemoSpec
<-
function
(
matrix_to_ChemoSpec
<-
function
(
data
,
data
,
groups
,
groups
=
"{missing group}"
,
...
)
{
...
)
{
checkmate
::
assert_matrix
(
checkmate
::
assert_matrix
(
data
,
data
,
...
@@ -208,7 +215,7 @@ matrix_to_ChemoSpec <- function(
...
@@ -208,7 +215,7 @@ matrix_to_ChemoSpec <- function(
#' @seealso `to_ChemoSpec()`
#' @seealso `to_ChemoSpec()`
simplerspec_to_ChemoSpec
<-
function
(
simplerspec_to_ChemoSpec
<-
function
(
spc_tbl
,
spc_tbl
,
groups
,
groups
=
"{missing group}"
,
data_column
=
base
::
c
(
"spc_pre"
,
"spc_mean"
,
"spc_rs"
,
"spc"
),
data_column
=
base
::
c
(
"spc_pre"
,
"spc_mean"
,
"spc_rs"
,
"spc"
),
freq_column
=
base
::
c
(
"xvalues_pre"
,
"wavenumbers_rs"
,
"wavenumbers"
),
freq_column
=
base
::
c
(
"xvalues_pre"
,
"wavenumbers_rs"
,
"wavenumbers"
),
name_column
=
base
::
c
(
"unique_id"
,
"file_id"
,
"sample_id"
,
"sample_name"
),
name_column
=
base
::
c
(
"unique_id"
,
"file_id"
,
"sample_id"
,
"sample_name"
),
...
@@ -333,7 +340,7 @@ opusreader2_to_ChemoSpec <- function(
...
@@ -333,7 +340,7 @@ opusreader2_to_ChemoSpec <- function(
#' @export
#' @export
#' @keywords from_hyperSpec to_ChemoSpec
#' @keywords from_hyperSpec to_ChemoSpec
#' @seealso `to_ChemoSpec()`, `ChemoSpec_to_hyperSpec()`
#' @seealso `to_ChemoSpec()`, `ChemoSpec_to_hyperSpec()`
hyperSpec_to_ChemoSpec
<-
function
(
hySpc
,
names
,
groups
,
...
)
{
hyperSpec_to_ChemoSpec
<-
function
(
hySpc
,
names
,
groups
=
"{missing group}"
,
...
)
{
to_ChemoSpec
(
to_ChemoSpec
(
data
=
hySpc
[[]],
data
=
hySpc
[[]],
freq
=
hySpc
|>
hyperSpec
::
wl
(),
freq
=
hySpc
|>
hyperSpec
::
wl
(),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment