Learn R Programming

dtGAP (version 0.0.2)

sorted_mat: Sort Feature Matrix by Tree and Correlation Structure

Description

Orders samples and features based on tree-derived node grouping and correlation-based seriation.

Usage

sorted_mat(
  tree_res = NULL,
  target_lab = NULL,
  show = c("all", "train", "test"),
  trans_type = c("normalize", "scale", "percentize", "none"),
  col_proximity = c("pearson", "spearman", "kendall"),
  linkage_method = c("CT", "SG", "CP"),
  seriate_method = "TSP",
  w = 5,
  sort_by_data_type = TRUE
)

Value

A list with:

  • sorted_row_names, sorted_col_names

  • row_pro_mat_sorted, col_pro_mat_sorted

  • cRGAR_score

  • sorted_test_matrix

  • node_ids

  • dat_sorted

Arguments

tree_res

A list returned by compute_tree(), containing fit, dat, and plot_data.

target_lab

Character. Name of the target column to exclude from features.

show

Character. "train","test", or "all" to select subset before sorting.

trans_type

Character. One of "percentize","normalize","scale","none" passed to scale_norm().

col_proximity

Character. Correlation method: "pearson","spearman","kendall".

linkage_method

Character. Linkage for supervised distance: "CT","SG","CP".

seriate_method

Character. Seriation method for distance objects; see seriation::list_seriation_methods("dist") for all supported options. Default: "TSP".

w

Integer. Window size for RGAR calculation.

sort_by_data_type

Logical. If TRUE, preserves data_type grouping within nodes.

Examples

Run this code
# \donttest{
library(rpart)
library(partykit)
library(ggparty)
library(dplyr)
library(seriation)
data <- add_data_type(
  data_all = Psychosis_Disorder
)
data <- prepare_features(
  data,
  target_lab = "UNIQID",
  task = "classification"
)
fit <- train_tree(
  data = data, target_lab = "UNIQID",
  model = "rpart"
)$fit
tree_res <- compute_tree(
  fit,
  model = "rpart", show = "all",
  data = data, target_lab = "UNIQID",
  task = "classification"
)
sorted_dat <- sorted_mat(
  tree_res,
  target_lab = "UNIQID",
  show = "all", trans_type = "none",
  seriate_method = "GW_average",
  sort_by_data_type = FALSE
)
sorted_dat$row_pro_mat_sorted
sorted_dat$col_pro_mat_sorted
sorted_dat$cRGAR_score
# }

Run the code above in your browser using DataLab