response_as_matrix: Extract response column of a protein into matrix

View source: R/tidyMS_aggregation.R

response_as_matrixR Documentation

Extract response column of a protein into matrix

Description

Used to apply the median polish function working on matrices to a tidy table

Usage

response_as_matrix(pdata, config)

Examples

library(dplyr)

bb <- prolfqua_data('data_ionstar')$filtered()
bb$config <- old2new(bb$config)
stopifnot(nrow(bb$data) == 25780)
configur <- bb$config
data <- bb$data

xnested <- data |>
 dplyr::group_by_at( configur$table$hierarchy_keys_depth() ) |>
 tidyr::nest()
x <- xnested$data[[1]]
nn  <- x |> dplyr::select( base::setdiff(configur$table$hierarchy_keys() ,
  configur$table$hierarchy_keys_depth()) ) |>
 dplyr::distinct() |> nrow()

xx <- response_as_matrix(x,configur)
stopifnot(dim(xx)==c(nn,20))

# change hierarchyDepth ###################
conf <- configur$clone(deep=TRUE)
conf$table$hierarchyDepth = 1

xnested <- data |>
 dplyr::group_by_at(conf$table$hierarchy_keys_depth()) |>
 tidyr::nest()

x <- xnested$data[[1]]
nn  <- x |> dplyr::select( base::setdiff(configur$table$hierarchy_keys(),
  configur$table$hierarchy_keys_depth()) ) |>
 dplyr::distinct() |> nrow()

xx <- response_as_matrix(x,conf)
stopifnot(dim(xx)==c(nn,20))


wolski/prolfqua documentation built on Dec. 4, 2024, 11:18 p.m.