Load libraries

#list all the packages we will need
packages <- c(
  "tidyverse",    # data wrangling + ggplot2
  "corrplot",     # correlation matrices
  "ggcorrplot",   # ggplot2-style correlation matrices
  "scales",       # axis formatting
  "knitr",        # table rendering
  "kableExtra",   # styled tables
  "DT",           # interactive tables
  "RColorBrewer", # colour palettes
  "patchwork",    # combine ggplots
  "glue",         # string interpolation
  "plotly"        # hover ggplots 
)

#check what's installed
installed  <- rownames(installed.packages())

#find what needs to be installed
to_install <- setdiff(packages, installed)

#install missing packages
if (length(to_install) > 0) {
  message("Installing missing packages: ", paste(to_install, collapse = ", "))
  install.packages(to_install, repos = "https://cloud.r-project.org")
} else {
  message("All packages already installed.")
}

#load all packages
invisible(lapply(packages, library, character.only = TRUE))

#clean up env
rm(packages, installed, to_install)

Set file paths

#set main data directory 

DATA_DIR <- "/Users/oviya/Desktop/100um/lusebrink_left_features_allclasses_allimages_250um.csv"
df <- read_csv(DATA_DIR, show_col_types = FALSE)



#dim(df)
#names(df)

# assign a unique ID to each voxel
df <- df |>
  mutate(voxel_id = row_number(), .before = 1)

# compact data summary
cat("Number of voxels:", nrow(df), "\n")
## Number of voxels: 107879
cat("Number of columns:", ncol(df), "\n")
## Number of columns: 284
names(df)[1:15]
##  [1] "voxel_id"                                       
##  [2] "x"                                              
##  [3] "y"                                              
##  [4] "z"                                              
##  [5] "y_global"                                       
##  [6] "original_glrlm_GrayLevelNonUniformity"          
##  [7] "original_glrlm_GrayLevelNonUniformityNormalized"
##  [8] "original_glrlm_GrayLevelVariance"               
##  [9] "original_glrlm_HighGrayLevelRunEmphasis"        
## [10] "original_glrlm_LongRunEmphasis"                 
## [11] "original_glrlm_LongRunHighGrayLevelEmphasis"    
## [12] "original_glrlm_LongRunLowGrayLevelEmphasis"     
## [13] "original_glrlm_LowGrayLevelRunEmphasis"         
## [14] "original_glrlm_RunEntropy"                      
## [15] "original_glrlm_RunLengthNonUniformity"

Separate metadata and radiomic features

# Save voxel location information separately
voxel_metadata <- df |>
  select(voxel_id, x, y, z, y_global)

# Keep only radiomic features for preprocessing/PCA
feature_df <- df |>
  select(-voxel_id, -x, -y, -z, -y_global)

cat("Number of voxels:", nrow(feature_df), "\n")
## Number of voxels: 107879
cat("Radiomic features:", ncol(feature_df), "\n")
## Radiomic features: 279

Troubleshoot missing/invalid values

# Check each radiomic feature for missing or infinite values
value_qc <- tibble(
  feature = names(feature_df),
  n_missing = sapply(feature_df, function(x) sum(is.na(x))),
  n_infinite = sapply(feature_df, function(x) sum(is.infinite(x))),
  n_nonfinite = sapply(feature_df, function(x) sum(!is.finite(x)))
) |>
  mutate(
    percent_nonfinite = 100 * n_nonfinite / nrow(feature_df)
  )

# Only keep features that actually have a problem
problem_features <- value_qc |>
  filter(n_nonfinite > 0) |>
  arrange(desc(n_nonfinite))

cat("Radiomic features checked:", nrow(value_qc), "\n")
## Radiomic features checked: 279
cat("Features with missing/invalid values:", nrow(problem_features), "\n")
## Features with missing/invalid values: 3
problem_features
## # A tibble: 3 × 5
##   feature                     n_missing n_infinite n_nonfinite percent_nonfinite
##   <chr>                           <int>      <int>       <int>             <dbl>
## 1 original_glcm_JointAverage        742          0         742             0.688
## 2 logSigma0p5_glcm_JointAver…       742          0         742             0.688
## 3 logSigma1p0_glcm_JointAver…       742          0         742             0.688

Removing Joint Average, zero variance features

#extra step since PCA will fail with na values
feature_df_pca <- feature_df |>
  select(-all_of(problem_features$feature))

sum(!is.finite(as.matrix(feature_df_pca)))
## [1] 0
#AT 276 radiomic features NOW for lusebrink left
# Calculate standard deviation of each feature
feature_sd <- sapply(feature_df_pca, sd)

# Find features that do not vary across voxels
zero_variance_features <- names(feature_sd)[
  !is.finite(feature_sd) | feature_sd == 0
]

cat("Zero-variance features:", length(zero_variance_features), "\n")
## Zero-variance features: 3
zero_variance_features
## [1] "original_glcm_MCC"    "logSigma0p5_glcm_MCC" "logSigma1p0_glcm_MCC"
sapply(
  feature_df_pca[, zero_variance_features],
  function(x) c(
    min = min(x),
    max = max(x),
    unique_values = length(unique(x))
  )
)
##               original_glcm_MCC logSigma0p5_glcm_MCC logSigma1p0_glcm_MCC
## min                           0                    0                    0
## max                           0                    0                    0
## unique_values                 1                    1                    1
#removing
feature_df_pca <- feature_df_pca |>
  select(-all_of(zero_variance_features))

cat("Radiomic features remaining for PCA:", ncol(feature_df_pca), "\n")
## Radiomic features remaining for PCA: 273
#AT 274 radiomic features NOW for lusebrink left

Z-score

# Z-score every radiomic feature
feature_z <- sapply(
  feature_df_pca,
  function(x) (x - mean(x)) / sd(x)
)

cat("Voxels:", nrow(feature_z), "\n")
## Voxels: 107879
cat("Z-scored radiomic features:", ncol(feature_z), "\n")
## Z-scored radiomic features: 273
cat(
  "Largest absolute mean:",
  max(abs(colMeans(feature_z))),
  "\n"
)
## Largest absolute mean: 4.564971e-14
cat(
  "Smallest SD:",
  min(apply(feature_z, 2, sd)),
  "\n"
)
## Smallest SD: 1
cat(
  "Largest SD:",
  max(apply(feature_z, 2, sd)),
  "\n"
)
## Largest SD: 1
head(feature_z)
##      original_glrlm_GrayLevelNonUniformity
## [1,]                             -2.560047
## [2,]                             -2.539655
## [3,]                             -2.503422
## [4,]                             -2.505534
## [5,]                             -2.422106
## [6,]                             -2.233076
##      original_glrlm_GrayLevelNonUniformityNormalized
## [1,]                                        6.451088
## [2,]                                        3.122198
## [3,]                                        2.868279
## [4,]                                        4.179760
## [5,]                                        2.852392
## [6,]                                        2.465889
##      original_glrlm_GrayLevelVariance original_glrlm_HighGrayLevelRunEmphasis
## [1,]                       -0.9734832                               -1.347461
## [2,]                       -1.1900422                               -1.261090
## [3,]                       -1.0480431                               -1.203407
## [4,]                       -1.0067566                               -1.220955
## [5,]                       -1.0833657                               -1.145167
## [6,]                       -1.2290636                               -1.186123
##      original_glrlm_LongRunEmphasis original_glrlm_LongRunHighGrayLevelEmphasis
## [1,]                      3.9903123                                   -1.184403
## [2,]                      3.3243167                                   -1.124860
## [3,]                      2.7584666                                   -1.103078
## [4,]                      4.0097722                                   -1.062337
## [5,]                      0.7011627                                   -1.080458
## [6,]                      0.4934581                                   -1.137705
##      original_glrlm_LongRunLowGrayLevelEmphasis
## [1,]                                  0.7623620
## [2,]                                  0.5455086
## [3,]                                  0.4655579
## [4,]                                  0.5838678
## [5,]                                  0.2082965
## [6,]                                  0.2031703
##      original_glrlm_LowGrayLevelRunEmphasis original_glrlm_RunEntropy
## [1,]                              0.4204312                 -4.579641
## [2,]                              0.2599864                 -2.776094
## [3,]                              0.2138956                 -2.796025
## [4,]                              0.2462174                 -3.368615
## [5,]                              0.1531713                 -3.040376
## [6,]                              0.1598882                 -3.017110
##      original_glrlm_RunLengthNonUniformity
## [1,]                             -3.733618
## [2,]                             -3.549743
## [3,]                             -3.498736
## [4,]                             -3.600400
## [5,]                             -3.405246
## [6,]                             -3.198915
##      original_glrlm_RunLengthNonUniformityNormalized
## [1,]                                      -4.1172759
## [2,]                                      -2.2525621
## [3,]                                      -1.8224574
## [4,]                                      -2.7504829
## [5,]                                      -0.5350303
## [6,]                                       0.2437575
##      original_glrlm_RunPercentage original_glrlm_RunVariance
## [1,]                   -3.8957740                  2.0514299
## [2,]                   -2.6320693                  3.2155809
## [3,]                   -2.1889512                  2.7692745
## [4,]                   -3.1490384                  3.7296980
## [5,]                   -0.5247994                 -0.2758418
## [6,]                    0.1130138                 -0.1570502
##      original_glrlm_ShortRunEmphasis
## [1,]                      -5.3963910
## [2,]                      -2.6727414
## [3,]                      -2.1424110
## [4,]                      -3.3132986
## [5,]                      -1.3115096
## [6,]                      -0.4051717
##      original_glrlm_ShortRunHighGrayLevelEmphasis
## [1,]                                    -1.400483
## [2,]                                    -1.280935
## [3,]                                    -1.214460
## [4,]                                    -1.245689
## [5,]                                    -1.168250
## [6,]                                    -1.194819
##      original_glrlm_ShortRunLowGrayLevelEmphasis
## [1,]                                   0.3068558
## [2,]                                   0.1935473
## [3,]                                   0.1556469
## [4,]                                   0.1668380
## [5,]                                   0.1303209
## [6,]                                   0.1504791
##      logSigma0p5_glrlm_GrayLevelNonUniformity
## [1,]                                -2.476228
## [2,]                                -2.504767
## [3,]                                -2.423868
## [4,]                                -2.391330
## [5,]                                -2.328886
## [6,]                                -2.345865
##      logSigma0p5_glrlm_GrayLevelNonUniformityNormalized
## [1,]                                          2.0132779
## [2,]                                          0.1761409
## [3,]                                          0.5602681
## [4,]                                          1.4240068
## [5,]                                          0.7709692
## [6,]                                         -0.1000714
##      logSigma0p5_glrlm_GrayLevelVariance
## [1,]                          -0.9711660
## [2,]                          -0.5744730
## [3,]                          -0.7282570
## [4,]                          -0.9713863
## [5,]                          -0.7328698
## [6,]                          -0.3393020
##      logSigma0p5_glrlm_HighGrayLevelRunEmphasis
## [1,]                                 -0.4813450
## [2,]                                 -0.5966887
## [3,]                                 -0.4023485
## [4,]                                 -0.2418087
## [5,]                                 -0.8941178
## [6,]                                 -0.6228711
##      logSigma0p5_glrlm_LongRunEmphasis
## [1,]                        -0.9627644
## [2,]                        -1.8311554
## [3,]                        -0.9961641
## [4,]                        -0.7496140
## [5,]                        -1.5210162
## [6,]                        -1.7025044
##      logSigma0p5_glrlm_LongRunHighGrayLevelEmphasis
## [1,]                                     -0.5706888
## [2,]                                     -0.8606667
## [3,]                                     -0.4994477
## [4,]                                     -0.3261276
## [5,]                                     -1.0516023
## [6,]                                     -0.8798651
##      logSigma0p5_glrlm_LongRunLowGrayLevelEmphasis
## [1,]                                    -0.3206913
## [2,]                                    -0.2924976
## [3,]                                    -0.3237623
## [4,]                                    -0.3525173
## [5,]                                    -0.1936313
## [6,]                                    -0.2541006
##      logSigma0p5_glrlm_LowGrayLevelRunEmphasis logSigma0p5_glrlm_RunEntropy
## [1,]                                -0.2856468                   -3.2287197
## [2,]                                -0.2185732                   -1.4577650
## [3,]                                -0.2852642                   -1.8822694
## [4,]                                -0.3316148                   -2.7457222
## [5,]                                -0.1293798                   -1.9306524
## [6,]                                -0.1899757                   -0.9321961
##      logSigma0p5_glrlm_RunLengthNonUniformity
## [1,]                                -3.558218
## [2,]                                -3.308367
## [3,]                                -3.326385
## [4,]                                -3.431305
## [5,]                                -3.220728
## [6,]                                -3.013239
##      logSigma0p5_glrlm_RunLengthNonUniformityNormalized
## [1,]                                          0.7084739
## [2,]                                          2.1495774
## [3,]                                          0.7981139
## [4,]                                          0.4665914
## [5,]                                          1.8382587
## [6,]                                          2.0013867
##      logSigma0p5_glrlm_RunPercentage logSigma0p5_glrlm_RunVariance
## [1,]                       0.8846379                     -1.146343
## [2,]                       2.1063747                     -1.846247
## [3,]                       0.9513738                     -1.189879
## [4,]                       0.6510721                     -1.028868
## [5,]                       1.7922159                     -1.695048
## [6,]                       1.9664250                     -1.774275
##      logSigma0p5_glrlm_ShortRunEmphasis
## [1,]                          0.6954175
## [2,]                          2.0050264
## [3,]                          0.7457861
## [4,]                          0.3739678
## [5,]                          1.5373083
## [6,]                          1.8110115
##      logSigma0p5_glrlm_ShortRunHighGrayLevelEmphasis
## [1,]                                      -0.4746000
## [2,]                                      -0.5181904
## [3,]                                      -0.3953883
## [4,]                                      -0.2454720
## [5,]                                      -0.8463850
## [6,]                                      -0.5461545
##      logSigma0p5_glrlm_ShortRunLowGrayLevelEmphasis
## [1,]                                     -0.2781811
## [2,]                                     -0.1982677
## [3,]                                     -0.2765771
## [4,]                                     -0.3285068
## [5,]                                     -0.1138033
## [6,]                                     -0.1735659
##      logSigma1p0_glrlm_GrayLevelNonUniformity
## [1,]                                -1.936913
## [2,]                                -1.935010
## [3,]                                -1.810824
## [4,]                                -1.924444
## [5,]                                -1.675267
## [6,]                                -1.594931
##      logSigma1p0_glrlm_GrayLevelNonUniformityNormalized
## [1,]                                           3.374158
## [2,]                                           1.940656
## [3,]                                           2.197938
## [4,]                                           1.997633
## [5,]                                           2.497588
## [6,]                                           1.655282
##      logSigma1p0_glrlm_GrayLevelVariance
## [1,]                          -1.0731543
## [2,]                          -1.0108268
## [3,]                          -1.0242205
## [4,]                          -1.0169141
## [5,]                          -0.9737861
## [6,]                          -0.9497710
##      logSigma1p0_glrlm_HighGrayLevelRunEmphasis
## [1,]                                 -0.8381467
## [2,]                                 -0.7774815
## [3,]                                 -0.7745604
## [4,]                                 -0.7850321
## [5,]                                 -0.7250684
## [6,]                                 -0.7107874
##      logSigma1p0_glrlm_LongRunEmphasis
## [1,]                       0.961902300
## [2,]                       1.388663502
## [3,]                       0.901385518
## [4,]                       0.475017192
## [5,]                       0.670801812
## [6,]                      -0.009291596
##      logSigma1p0_glrlm_LongRunHighGrayLevelEmphasis
## [1,]                                     -0.6233443
## [2,]                                     -0.4864947
## [3,]                                     -0.5710819
## [4,]                                     -0.6506417
## [5,]                                     -0.5415666
## [6,]                                     -0.6434554
##      logSigma1p0_glrlm_LongRunLowGrayLevelEmphasis
## [1,]                                    -0.1452950
## [2,]                                    -0.1494013
## [3,]                                    -0.1644280
## [4,]                                    -0.1752655
## [5,]                                    -0.1889095
## [6,]                                    -0.2125669
##      logSigma1p0_glrlm_LowGrayLevelRunEmphasis logSigma1p0_glrlm_RunEntropy
## [1,]                                -0.2004882                    -3.505266
## [2,]                                -0.2210493                    -2.263817
## [3,]                                -0.2228827                    -2.536062
## [4,]                                -0.2186908                    -2.716442
## [5,]                                -0.2370311                    -2.570427
## [6,]                                -0.2405137                    -2.482514
##      logSigma1p0_glrlm_RunLengthNonUniformity
## [1,]                                -3.133224
## [2,]                                -3.073869
## [3,]                                -2.990668
## [4,]                                -3.009486
## [5,]                                -2.955597
## [6,]                                -2.727825
##      logSigma1p0_glrlm_RunLengthNonUniformityNormalized
## [1,]                                       -0.495007802
## [2,]                                       -1.495790017
## [3,]                                       -0.827776363
## [4,]                                       -0.231419867
## [5,]                                       -0.871217163
## [6,]                                        0.007794696
##      logSigma1p0_glrlm_RunPercentage logSigma1p0_glrlm_RunVariance
## [1,]                     -0.68358633                     1.3971287
## [2,]                     -1.44860380                     1.5196156
## [3,]                     -0.88654939                     1.1672654
## [4,]                     -0.32839799                     0.6835954
## [5,]                     -0.92714251                     0.5418202
## [6,]                     -0.03552473                    -0.0858389
##      logSigma1p0_glrlm_ShortRunEmphasis
## [1,]                         -0.5213469
## [2,]                         -1.3916788
## [3,]                         -0.7510268
## [4,]                         -0.3240169
## [5,]                         -1.1541857
## [6,]                         -0.1434742
##      logSigma1p0_glrlm_ShortRunHighGrayLevelEmphasis
## [1,]                                      -0.8642768
## [2,]                                      -0.8379145
## [3,]                                      -0.8097238
## [4,]                                      -0.8022174
## [5,]                                      -0.7798812
## [6,]                                      -0.7226172
##      logSigma1p0_glrlm_ShortRunLowGrayLevelEmphasis
## [1,]                                     -0.2096594
## [2,]                                     -0.2430348
## [3,]                                     -0.2371425
## [4,]                                     -0.2275611
## [5,]                                     -0.2557635
## [6,]                                     -0.2481459
##      original_firstorder_10Percentile original_firstorder_90Percentile
## [1,]                       -0.9408148                        -2.014974
## [2,]                       -0.8704143                        -1.772873
## [3,]                       -0.8698660                        -1.756351
## [4,]                       -0.8709622                        -1.759327
## [5,]                       -0.8693178                        -1.663791
## [6,]                       -0.8671250                        -1.666101
##      original_firstorder_Energy original_firstorder_Entropy
## [1,]                  -3.025923                   -5.209861
## [2,]                  -2.929134                   -3.485606
## [3,]                  -2.901986                   -3.450025
## [4,]                  -2.949386                   -3.267750
## [5,]                  -2.869192                   -2.889052
## [6,]                  -2.780289                   -3.108544
##      original_firstorder_InterquartileRange original_firstorder_Kurtosis
## [1,]                             -2.3165178                    2.8121464
## [2,]                             -1.5272368                   -0.3941607
## [3,]                             -1.1594968                   -0.2915026
## [4,]                             -1.3298399                   -0.1724087
## [5,]                             -0.9736844                   -1.3673699
## [6,]                             -1.3526745                   -0.9435086
##      original_firstorder_Maximum original_firstorder_MeanAbsoluteDeviation
## [1,]                   -2.073915                                 -2.076724
## [2,]                   -2.216722                                 -1.959361
## [3,]                   -2.073915                                 -1.760643
## [4,]                   -2.073915                                 -1.754683
## [5,]                   -2.216722                                 -1.407357
## [6,]                   -2.216722                                 -1.765717
##      original_firstorder_Mean original_firstorder_Median
## [1,]                -1.492334                  -1.476912
## [2,]                -1.388392                  -1.356388
## [3,]                -1.346214                  -1.346387
## [4,]                -1.366439                  -1.346387
## [5,]                -1.260626                  -1.157330
## [6,]                -1.292188                  -1.331150
##      original_firstorder_Minimum original_firstorder_Range
## [1,]                  -0.5689751                 -2.213642
## [2,]                  -0.5689751                 -2.430631
## [3,]                  -0.5689751                 -2.213642
## [4,]                  -0.5689751                 -2.213642
## [5,]                  -0.5689751                 -2.430631
## [6,]                  -0.5689751                 -2.430631
##      original_firstorder_RobustMeanAbsoluteDeviation
## [1,]                                       -2.459543
## [2,]                                       -2.058451
## [3,]                                       -1.807197
## [4,]                                       -1.998777
## [5,]                                       -1.034711
## [6,]                                       -1.365568
##      original_firstorder_RootMeanSquared original_firstorder_Skewness
## [1,]                           -1.515682                    3.0253155
## [2,]                           -1.413556                    0.2933370
## [3,]                           -1.369660                    0.4704974
## [4,]                           -1.389241                    0.7066534
## [5,]                           -1.283118                   -1.2501573
## [6,]                           -1.316997                   -0.6805505
##      original_firstorder_TotalEnergy original_firstorder_Uniformity
## [1,]                       -3.025923                       8.433786
## [2,]                       -2.929134                       4.947658
## [3,]                       -2.901986                       4.643742
## [4,]                       -2.949386                       4.164541
## [5,]                       -2.869192                       2.969153
## [6,]                       -2.780289                       3.608712
##      original_firstorder_Variance original_glcm_Autocorrelation
## [1,]                    -1.394617                     -1.414728
## [2,]                    -1.519219                     -1.340612
## [3,]                    -1.421524                     -1.305952
## [4,]                    -1.379325                     -1.320435
## [5,]                    -1.375783                     -1.179114
## [6,]                    -1.513649                     -1.229755
##      original_glcm_ClusterProminence original_glcm_ClusterShade
## [1,]                      -0.7238924                 0.04276802
## [2,]                      -0.7269473                -0.07451384
## [3,]                      -0.7076056                -0.01733243
## [4,]                      -0.7002823                 0.02772991
## [5,]                      -0.6760608                -0.24124993
## [6,]                      -0.6911256                -0.06892947
##      original_glcm_ClusterTendency original_glcm_Contrast
## [1,]                     -1.375028              -1.385804
## [2,]                     -1.342527              -1.605312
## [3,]                     -1.229611              -1.315042
## [4,]                     -1.195316              -1.250844
## [5,]                     -1.000628              -1.840380
## [6,]                     -1.094501              -1.863720
##      original_glcm_Correlation original_glcm_DifferenceAverage
## [1,]                 -2.407723                       -1.805200
## [2,]                 -1.544024                       -1.945708
## [3,]                 -1.297948                       -1.420653
## [4,]                 -1.222551                       -1.336137
## [5,]                  1.547766                       -2.547673
## [6,]                  1.226682                       -2.603876
##      original_glcm_DifferenceEntropy original_glcm_DifferenceVariance
## [1,]                       -3.982775                        -1.199863
## [2,]                       -3.511642                        -1.721408
## [3,]                       -2.515392                        -1.432090
## [4,]                       -2.331605                        -1.340303
## [5,]                       -4.035804                        -1.906958
## [6,]                       -3.855229                        -1.846356
##      original_glcm_Id original_glcm_Idm original_glcm_Idmn original_glcm_Idn
## [1,]         3.037838          2.935769           1.412529          1.892249
## [2,]         2.455702          2.380759           1.641083          2.009221
## [3,]         1.505657          1.361014           1.336560          1.434761
## [4,]         1.447580          1.306999           1.269399          1.346835
## [5,]         3.985691          3.995268           1.889761          2.692458
## [6,]         3.986745          4.135659           1.914657          2.755587
##      original_glcm_Imc1 original_glcm_Imc2 original_glcm_InverseVariance
## [1,]          -1.815524        -0.70343273                   -0.02009731
## [2,]          -1.170595        -0.07066675                    1.06750803
## [3,]          -1.131774         0.10425478                    0.29461367
## [4,]          -1.471696         0.30564082                    0.19010758
## [5,]          -2.072966         0.76085459                    1.54883087
## [6,]          -1.317764         0.50941812                    2.69802563
##      original_glcm_JointEnergy original_glcm_JointEntropy
## [1,]                  7.933110                  -5.176124
## [2,]                  3.603452                  -3.630895
## [3,]                  3.077546                  -3.338156
## [4,]                  3.111050                  -3.410323
## [5,]                  3.064322                  -3.462083
## [6,]                  2.294896                  -2.880679
##      original_glcm_MaximumProbability original_glcm_SumAverage
## [1,]                         7.050276                -1.604093
## [2,]                         4.147653                -1.484730
## [3,]                         3.431260                -1.430269
## [4,]                         3.874153                -1.453575
## [5,]                         2.134343                -1.250780
## [6,]                         2.523894                -1.322852
##      original_glcm_SumEntropy original_glcm_SumSquares
## [1,]                -4.592340                -1.444601
## [2,]                -3.225862                -1.471366
## [3,]                -2.959597                -1.310127
## [4,]                -2.976572                -1.266942
## [5,]                -2.472662                -1.252124
## [6,]                -2.116427                -1.333539
##      original_glszm_GrayLevelNonUniformity
## [1,]                             -3.041318
## [2,]                             -3.244218
## [3,]                             -2.863780
## [4,]                             -3.244218
## [5,]                             -2.863780
## [6,]                             -2.863780
##      original_glszm_GrayLevelNonUniformityNormalized
## [1,]                                        8.425394
## [2,]                                        3.951811
## [3,]                                        4.129522
## [4,]                                        3.951811
## [5,]                                        4.129522
## [6,]                                        4.129522
##      original_glszm_GrayLevelVariance original_glszm_HighGrayLevelZoneEmphasis
## [1,]                        -1.331478                                -1.433549
## [2,]                        -1.709975                                -1.401894
## [3,]                        -1.579775                                -1.342916
## [4,]                        -1.476541                                -1.324759
## [5,]                        -1.729775                                -1.368335
## [6,]                        -1.729775                                -1.368335
##      original_glszm_LargeAreaEmphasis
## [1,]                       -1.1624613
## [2,]                       -1.1270006
## [3,]                       -1.1590137
## [4,]                       -1.1565512
## [5,]                       -1.1503948
## [6,]                       -0.9435408
##      original_glszm_LargeAreaHighGrayLevelEmphasis
## [1,]                                    -1.0861602
## [2,]                                    -1.0682996
## [3,]                                    -1.0770239
## [4,]                                    -1.0796204
## [5,]                                    -1.0539643
## [6,]                                    -0.9870661
##      original_glszm_LargeAreaLowGrayLevelEmphasis
## [1,]                                   -0.5270258
## [2,]                                   -0.5134439
## [3,]                                   -0.5480042
## [4,]                                   -0.5368656
## [5,]                                   -0.5796727
## [6,]                                   -0.3838326
##      original_glszm_LowGrayLevelZoneEmphasis
## [1,]                               0.7341834
## [2,]                               0.5978199
## [3,]                               0.5202497
## [4,]                               0.5177911
## [5,]                               0.5355742
## [6,]                               0.5355742
##      original_glszm_SizeZoneNonUniformity
## [1,]                            -2.007295
## [2,]                            -1.979227
## [3,]                            -1.786258
## [4,]                            -1.698545
## [5,]                            -1.847657
## [6,]                            -2.031855
##      original_glszm_SizeZoneNonUniformityNormalized
## [1,]                                      2.3643044
## [2,]                                      0.7566926
## [3,]                                      1.3614077
## [4,]                                      2.7413984
## [5,]                                      0.9815226
## [6,]                                     -0.1581328
##      original_glszm_SmallAreaEmphasis
## [1,]                       0.90345391
## [2,]                       0.75841640
## [3,]                       1.29223269
## [4,]                       2.00158863
## [5,]                       0.07352176
## [6,]                      -1.31883117
##      original_glszm_SmallAreaHighGrayLevelEmphasis
## [1,]                                    -1.1807568
## [2,]                                    -1.2173364
## [3,]                                    -1.0544127
## [4,]                                    -0.8854108
## [5,]                                    -1.3698028
## [6,]                                    -1.5353828
##      original_glszm_SmallAreaLowGrayLevelEmphasis original_glszm_ZoneEntropy
## [1,]                                    0.7650348                  -6.118086
## [2,]                                    0.6344809                  -4.711145
## [3,]                                    0.6239996                  -4.152791
## [4,]                                    0.6884609                  -5.539248
## [5,]                                    0.5528108                  -4.877380
## [6,]                                    0.2913006                  -4.152791
##      original_glszm_ZonePercentage original_glszm_ZoneVariance
## [1,]                     1.9474647                   -1.114329
## [2,]                     1.7727344                   -1.083094
## [3,]                     2.1097140                   -1.091055
## [4,]                     2.2314004                   -1.074743
## [5,]                     1.7203153                   -1.124624
## [6,]                     0.5726139                   -1.035106
##      original_ngtdm_Busyness original_ngtdm_Coarseness
## [1,]              -0.3582365                 14.391187
## [2,]              -0.5477449                  8.675964
## [3,]              -0.4589173                  7.817936
## [4,]              -0.5308272                 10.053452
## [5,]              -0.8446298                 14.523524
## [6,]              -0.4229481                  9.264893
##      original_ngtdm_Complexity original_ngtdm_Contrast original_ngtdm_Strength
## [1,]                 -1.552642               6.2754620              1.08840943
## [2,]                 -1.489925               0.2499783              0.01338156
## [3,]                 -1.440177               1.1803216              0.13526070
## [4,]                 -1.433508               1.6326766              0.44736405
## [5,]                 -1.568371               0.1043929              0.77931474
## [6,]                 -1.575030              -0.5452118              0.22407598
##      original_gldm_DependenceEntropy original_gldm_DependenceNonUniformity
## [1,]                       -7.064811                             -3.422023
## [2,]                       -5.857913                             -3.165494
## [3,]                       -5.416368                             -3.092739
## [4,]                       -6.348426                             -3.140030
## [5,]                       -6.347031                             -2.647156
## [6,]                       -5.423752                             -2.170156
##      original_gldm_DependenceNonUniformityNormalized
## [1,]                                        3.034640
## [2,]                                        2.619357
## [3,]                                        2.608479
## [4,]                                        3.374433
## [5,]                                        4.853461
## [6,]                                        5.238890
##      original_gldm_DependenceVariance original_gldm_GrayLevelNonUniformity
## [1,]                        -1.578013                            -2.294939
## [2,]                        -1.641594                            -2.248076
## [3,]                        -1.619155                            -2.207907
## [4,]                        -1.523394                            -2.396476
## [5,]                        -1.585958                            -2.335554
## [6,]                        -1.739161                            -2.006361
##      original_gldm_GrayLevelVariance original_gldm_HighGrayLevelEmphasis
## [1,]                       -1.297727                           -1.404072
## [2,]                       -1.481861                           -1.352919
## [3,]                       -1.359454                           -1.318041
## [4,]                       -1.307410                           -1.333122
## [5,]                       -1.300767                           -1.235314
## [6,]                       -1.423183                           -1.268279
##      original_gldm_LargeDependenceEmphasis
## [1,]                             -1.626174
## [2,]                             -1.677201
## [3,]                             -1.742809
## [4,]                             -1.715472
## [5,]                             -1.401651
## [6,]                             -1.290464
##      original_gldm_LargeDependenceHighGrayLevelEmphasis
## [1,]                                          -1.419469
## [2,]                                          -1.410817
## [3,]                                          -1.423076
## [4,]                                          -1.429302
## [5,]                                          -1.258558
## [6,]                                          -1.250983
##      original_gldm_LargeDependenceLowGrayLevelEmphasis
## [1,]                                        -0.2100587
## [2,]                                        -0.2991447
## [3,]                                        -0.3475380
## [4,]                                        -0.3002039
## [5,]                                        -0.2925792
## [6,]                                        -0.1954794
##      original_gldm_LowGrayLevelEmphasis original_gldm_SmallDependenceEmphasis
## [1,]                          0.9874801                             1.7167585
## [2,]                          0.8206878                             1.5869862
## [3,]                          0.7659767                             2.0730281
## [4,]                          0.8129318                             2.5052665
## [5,]                          0.6195871                             0.8659032
## [6,]                          0.6490473                            -0.1555866
##      original_gldm_SmallDependenceHighGrayLevelEmphasis
## [1,]                                         -0.7627582
## [2,]                                         -0.7868709
## [3,]                                         -0.5995942
## [4,]                                         -0.4515461
## [5,]                                         -0.9601035
## [6,]                                         -1.1618620
##      original_gldm_SmallDependenceLowGrayLevelEmphasis
## [1,]                                         1.4058732
## [2,]                                         1.1976387
## [3,]                                         1.2596459
## [4,]                                         1.3682758
## [5,]                                         0.9343297
## [6,]                                         0.5126795
##      logSigma0p5_firstorder_10Percentile logSigma0p5_firstorder_90Percentile
## [1,]                          0.04049022                          -0.6516502
## [2,]                         -0.36323741                          -0.7294122
## [3,]                         -0.11733416                          -0.5244329
## [4,]                          0.36293323                          -0.5116257
## [5,]                         -0.69394855                          -1.0141267
## [6,]                         -0.59081877                          -0.6337010
##      logSigma0p5_firstorder_Energy logSigma0p5_firstorder_Entropy
## [1,]                     -1.182923                     -1.3402856
## [2,]                     -1.132549                     -0.8015463
## [3,]                     -1.155260                     -1.2009304
## [4,]                     -1.187258                     -2.0689084
## [5,]                     -1.070791                     -1.1977266
## [6,]                     -1.060556                     -0.3005629
##      logSigma0p5_firstorder_InterquartileRange logSigma0p5_firstorder_Kurtosis
## [1,]                                -0.7011394                      -1.3490739
## [2,]                                -0.2711237                      -1.0083476
## [3,]                                -0.1734865                      -1.2936397
## [4,]                                -0.2339081                      -1.4994632
## [5,]                                -0.5944298                      -0.9186914
## [6,]                                 0.1154460                      -1.0848708
##      logSigma0p5_firstorder_Maximum
## [1,]                     -1.2113675
## [2,]                     -1.1225728
## [3,]                     -1.1225728
## [4,]                     -1.1225728
## [5,]                     -1.5264618
## [6,]                     -0.9030344
##      logSigma0p5_firstorder_MeanAbsoluteDeviation logSigma0p5_firstorder_Mean
## [1,]                                  -0.61016709                 -0.37817526
## [2,]                                  -0.23894792                 -0.58624375
## [3,]                                  -0.28048926                 -0.30294289
## [4,]                                  -0.73672653                 -0.08991954
## [5,]                                  -0.50973500                 -0.97785876
## [6,]                                   0.05005424                 -0.65535469
##      logSigma0p5_firstorder_Median logSigma0p5_firstorder_Minimum
## [1,]                   -0.38212999                      0.5766352
## [2,]                   -0.68586964                     -0.0294031
## [3,]                   -0.18272453                      0.3808436
## [4,]                    0.02775344                      0.9036080
## [5,]                   -0.85731923                     -0.1749970
## [6,]                   -0.70724225                     -0.1749970
##      logSigma0p5_firstorder_Range
## [1,]                   -1.5431027
## [2,]                   -0.9642382
## [3,]                   -1.3031594
## [4,]                   -1.7350360
## [5,]                   -1.1996190
## [6,]                   -0.6506333
##      logSigma0p5_firstorder_RobustMeanAbsoluteDeviation
## [1,]                                         -0.3658755
## [2,]                                         -0.3785706
## [3,]                                         -0.1766443
## [4,]                                         -0.6496464
## [5,]                                         -0.5907562
## [6,]                                          0.1789038
##      logSigma0p5_firstorder_RootMeanSquared logSigma0p5_firstorder_Skewness
## [1,]                             -1.1097862                      0.06817717
## [2,]                             -0.6358681                     -0.12122118
## [3,]                             -0.9998419                     -0.30753952
## [4,]                             -1.4162813                     -0.26958501
## [5,]                             -0.1736850                      0.29499927
## [6,]                             -0.3821549                      0.16254665
##      logSigma0p5_firstorder_TotalEnergy logSigma0p5_firstorder_Uniformity
## [1,]                          -1.182923                         0.9760976
## [2,]                          -1.132549                         0.6759736
## [3,]                          -1.155260                         1.0422974
## [4,]                          -1.187258                         2.1187951
## [5,]                          -1.070791                         1.0704626
## [6,]                          -1.060556                         0.2523519
##      logSigma0p5_firstorder_Variance logSigma0p5_glcm_Autocorrelation
## [1,]                      -0.7255627                        0.1746908
## [2,]                      -0.4300489                        0.0557303
## [3,]                      -0.5343386                        0.2803233
## [4,]                      -0.8300997                        0.4542127
## [5,]                      -0.5753588                       -0.3412804
## [6,]                      -0.1818485                       -0.0194317
##      logSigma0p5_glcm_ClusterProminence logSigma0p5_glcm_ClusterShade
## [1,]                         -0.5088320                    0.26682398
## [2,]                         -0.4226448                    0.09053653
## [3,]                         -0.4205371                    0.12309670
## [4,]                         -0.4997205                    0.19732788
## [5,]                         -0.4149395                   -0.05261232
## [6,]                         -0.2095275                   -0.16141993
##      logSigma0p5_glcm_ClusterTendency logSigma0p5_glcm_Contrast
## [1,]                      -0.81759190                -0.5738645
## [2,]                      -0.46767357                -0.4749432
## [3,]                      -0.40770963                -0.6385973
## [4,]                      -0.71514815                -0.7162965
## [5,]                      -0.40776476                -0.3194456
## [6,]                       0.07182651                -0.3624850
##      logSigma0p5_glcm_Correlation logSigma0p5_glcm_DifferenceAverage
## [1,]                  -1.07186587                       -0.332232278
## [2,]                  -0.09548323                       -0.159975094
## [3,]                   0.44611539                       -0.524011496
## [4,]                  -0.39934323                       -0.733344718
## [5,]                  -0.16360146                       -0.008389076
## [6,]                   0.87814697                       -0.049730748
##      logSigma0p5_glcm_DifferenceEntropy logSigma0p5_glcm_DifferenceVariance
## [1,]                         -1.8714358                          -1.2795449
## [2,]                         -1.4113002                          -1.1270936
## [3,]                         -0.8844938                          -0.8689450
## [4,]                         -1.2477748                          -0.8918188
## [5,]                         -1.5198118                          -0.7846942
## [6,]                         -1.0173759                          -0.8449802
##      logSigma0p5_glcm_Id logSigma0p5_glcm_Idm logSigma0p5_glcm_Idmn
## [1,]          -0.2906757           -0.3271286             0.5727578
## [2,]          -0.4728820           -0.5561430             0.4696924
## [3,]           0.3191408            0.2242377             0.6395747
## [4,]           0.8011547            0.7313334             0.7206540
## [5,]          -0.3464866           -0.4958217             0.3091109
## [6,]          -0.4390926           -0.5366889             0.3538611
##      logSigma0p5_glcm_Idn logSigma0p5_glcm_Imc1 logSigma0p5_glcm_Imc2
## [1,]          0.283472719             -3.324688             0.8655158
## [2,]          0.099082592             -2.657257             0.8773488
## [3,]          0.499353237             -2.287979             0.7740012
## [4,]          0.732819545             -2.034977             0.4970694
## [5,]         -0.048858029             -2.693271             0.7563776
## [6,]         -0.008886277             -2.431019             0.9066245
##      logSigma0p5_glcm_InverseVariance logSigma0p5_glcm_JointEnergy
## [1,]                       0.44371868                     3.049718
## [2,]                      -0.13508047                     1.743550
## [3,]                      -0.15691036                     1.534498
## [4,]                       0.07721263                     2.317248
## [5,]                      -1.08011820                     2.839947
## [6,]                      -0.49369829                     1.128861
##      logSigma0p5_glcm_JointEntropy logSigma0p5_glcm_MaximumProbability
## [1,]                     -3.066602                            2.228603
## [2,]                     -2.211738                            1.908338
## [3,]                     -2.093922                            1.443953
## [4,]                     -2.604674                            2.091346
## [5,]                     -2.605034                            2.917173
## [6,]                     -1.574318                            1.485834
##      logSigma0p5_glcm_SumAverage logSigma0p5_glcm_SumEntropy
## [1,]                  0.31359024                   -3.172474
## [2,]                  0.18785243                   -2.020037
## [3,]                  0.39815305                   -1.718866
## [4,]                  0.56765876                   -2.307433
## [5,]                 -0.21681097                   -2.432194
## [6,]                  0.09392347                   -1.139407
##      logSigma0p5_glcm_SumSquares logSigma0p5_glszm_GrayLevelNonUniformity
## [1,]                -0.799111585                                -2.579089
## [2,]                -0.480690019                                -2.579089
## [3,]                -0.455165734                                -2.579089
## [4,]                -0.733449577                                -2.579089
## [5,]                -0.403892588                                -2.177097
## [6,]                 0.003807291                                -2.277595
##      logSigma0p5_glszm_GrayLevelNonUniformityNormalized
## [1,]                                          1.1629786
## [2,]                                          0.2037943
## [3,]                                          0.6234374
## [4,]                                          1.8823664
## [5,]                                          0.9498261
## [6,]                                         -0.2158486
##      logSigma0p5_glszm_GrayLevelVariance
## [1,]                         -0.84819485
## [2,]                         -0.43304339
## [3,]                         -0.64978191
## [4,]                         -1.03134993
## [5,]                         -0.90539068
## [6,]                         -0.01285113
##      logSigma0p5_glszm_HighGrayLevelZoneEmphasis
## [1,]                                  0.35161896
## [2,]                                  0.03360461
## [3,]                                  0.18733004
## [4,]                                  0.52863923
## [5,]                                 -0.48011047
## [6,]                                  0.03593968
##      logSigma0p5_glszm_LargeAreaEmphasis
## [1,]                          -1.0369682
## [2,]                          -1.0126476
## [3,]                          -0.9803600
## [4,]                          -0.9539428
## [5,]                          -0.9832952
## [6,]                          -0.9869643
##      logSigma0p5_glszm_LargeAreaHighGrayLevelEmphasis
## [1,]                                       -0.9351084
## [2,]                                       -0.9140185
## [3,]                                       -0.8696387
## [4,]                                       -0.8368011
## [5,]                                       -0.8978101
## [6,]                                       -0.8921620
##      logSigma0p5_glszm_LargeAreaLowGrayLevelEmphasis
## [1,]                                      -0.8265772
## [2,]                                      -0.8114818
## [3,]                                      -0.8007072
## [4,]                                      -0.7909433
## [5,]                                      -0.7862206
## [6,]                                      -0.7938920
##      logSigma0p5_glszm_LowGrayLevelZoneEmphasis
## [1,]                                 -0.4670430
## [2,]                                 -0.3525449
## [3,]                                 -0.4138981
## [4,]                                 -0.5140769
## [5,]                                 -0.1977950
## [6,]                                 -0.3183807
##      logSigma0p5_glszm_SizeZoneNonUniformity
## [1,]                             -0.60441557
## [2,]                             -0.21291060
## [3,]                             -0.58039137
## [4,]                             -0.86067330
## [5,]                             -0.56170587
## [6,]                              0.07359976
##      logSigma0p5_glszm_SizeZoneNonUniformityNormalized
## [1,]                                          3.612703
## [2,]                                          4.280009
## [3,]                                          2.965661
## [4,]                                          2.631923
## [5,]                                          2.434153
## [6,]                                          3.670217
##      logSigma0p5_glszm_SmallAreaEmphasis
## [1,]                           2.4945468
## [2,]                           2.6229259
## [3,]                           1.5823800
## [4,]                           0.7310241
## [5,]                           1.9430236
## [6,]                           2.4603406
##      logSigma0p5_glszm_SmallAreaHighGrayLevelEmphasis
## [1,]                                        1.9470835
## [2,]                                        1.4841271
## [3,]                                        0.8403372
## [4,]                                        0.7979588
## [5,]                                        0.3878808
## [6,]                                        1.5480132
##      logSigma0p5_glszm_SmallAreaLowGrayLevelEmphasis
## [1,]                                     -0.04749547
## [2,]                                      0.17971480
## [3,]                                     -0.03961571
## [4,]                                     -0.32891161
## [5,]                                      0.27029528
## [6,]                                      0.14720229
##      logSigma0p5_glszm_ZoneEntropy logSigma0p5_glszm_ZonePercentage
## [1,]                     -3.031713                         4.392089
## [2,]                     -2.249411                         3.631769
## [3,]                     -2.616051                         2.556459
## [4,]                     -3.511560                         1.921049
## [5,]                     -2.728890                         2.810623
## [6,]                     -1.713511                         3.091541
##      logSigma0p5_glszm_ZoneVariance logSigma0p5_ngtdm_Busyness
## [1,]                     -1.0189476                 -0.9461485
## [2,]                     -0.9952688                 -1.2398085
## [3,]                     -0.9833078                 -1.2375115
## [4,]                     -0.9802707                 -0.7647064
## [5,]                     -0.9748713                 -1.0560442
## [6,]                     -0.9684596                 -1.3147595
##      logSigma0p5_ngtdm_Coarseness logSigma0p5_ngtdm_Complexity
## [1,]                    13.052499                   -0.8460936
## [2,]                    12.000393                   -0.7089797
## [3,]                    11.642194                   -0.8460193
## [4,]                     6.655412                   -0.9396333
## [5,]                     7.996930                   -0.7467647
## [6,]                    11.075685                   -0.5755013
##      logSigma0p5_ngtdm_Contrast logSigma0p5_ngtdm_Strength
## [1,]                  2.6442012                  1.4757134
## [2,]                  1.2592605                  2.9072998
## [3,]                  1.4723109                  2.3301227
## [4,]                  3.0485634                  0.3530296
## [5,]                  1.4057456                  1.4358087
## [6,]                  0.4343477                  4.4721792
##      logSigma0p5_gldm_DependenceEntropy
## [1,]                          -5.993246
## [2,]                          -4.335032
## [3,]                          -4.858742
## [4,]                          -5.670414
## [5,]                          -4.714065
## [6,]                          -3.779364
##      logSigma0p5_gldm_DependenceNonUniformity
## [1,]                                -2.363511
## [2,]                                -2.219359
## [3,]                                -2.333089
## [4,]                                -2.438044
## [5,]                                -2.201667
## [6,]                                -1.895016
##      logSigma0p5_gldm_DependenceNonUniformityNormalized
## [1,]                                           5.728712
## [2,]                                           3.980120
## [3,]                                           2.702031
## [4,]                                           2.889370
## [5,]                                           3.117620
## [6,]                                           3.268046
##      logSigma0p5_gldm_DependenceVariance
## [1,]                           -1.423462
## [2,]                           -1.309497
## [3,]                           -1.244403
## [4,]                           -1.273289
## [5,]                           -1.303512
## [6,]                           -1.282457
##      logSigma0p5_gldm_GrayLevelNonUniformity logSigma0p5_gldm_GrayLevelVariance
## [1,]                               -2.360082                        -0.66094616
## [2,]                               -2.240802                        -0.38108298
## [3,]                               -2.150429                        -0.42796356
## [4,]                               -2.097027                        -0.74212918
## [5,]                               -2.105334                        -0.50894390
## [6,]                               -2.103585                        -0.03464992
##      logSigma0p5_gldm_HighGrayLevelEmphasis
## [1,]                             0.20643902
## [2,]                             0.01410757
## [3,]                             0.27652238
## [4,]                             0.46008011
## [5,]                            -0.34687820
## [6,]                            -0.03874614
##      logSigma0p5_gldm_LargeDependenceEmphasis
## [1,]                                -1.675049
## [2,]                                -1.588624
## [3,]                                -1.424262
## [4,]                                -1.359058
## [5,]                                -1.520564
## [6,]                                -1.538304
##      logSigma0p5_gldm_LargeDependenceHighGrayLevelEmphasis
## [1,]                                            -1.2234788
## [2,]                                            -1.1624655
## [3,]                                            -0.9654705
## [4,]                                            -0.8986138
## [5,]                                            -1.1462179
## [6,]                                            -1.1388192
##      logSigma0p5_gldm_LargeDependenceLowGrayLevelEmphasis
## [1,]                                           -0.7271970
## [2,]                                           -0.7025096
## [3,]                                           -0.6797995
## [4,]                                           -0.6687926
## [5,]                                           -0.6664962
## [6,]                                           -0.6792235
##      logSigma0p5_gldm_LowGrayLevelEmphasis
## [1,]                            -0.3833857
## [2,]                            -0.3157980
## [3,]                            -0.3851913
## [4,]                            -0.4381517
## [5,]                            -0.2028571
## [6,]                            -0.2751621
##      logSigma0p5_gldm_SmallDependenceEmphasis
## [1,]                                 4.669025
## [2,]                                 4.310517
## [3,]                                 2.588399
## [4,]                                 1.659052
## [5,]                                 3.154329
## [6,]                                 3.718507
##      logSigma0p5_gldm_SmallDependenceHighGrayLevelEmphasis
## [1,]                                              3.863058
## [2,]                                              2.958888
## [3,]                                              1.806973
## [4,]                                              1.570464
## [5,]                                              1.403011
## [6,]                                              2.669962
##      logSigma0p5_gldm_SmallDependenceLowGrayLevelEmphasis
## [1,]                                           0.51241010
## [2,]                                           0.69033094
## [3,]                                           0.25473796
## [4,]                                          -0.07720903
## [5,]                                           0.67433564
## [6,]                                           0.57557728
##      logSigma1p0_firstorder_10Percentile logSigma1p0_firstorder_90Percentile
## [1,]                         -0.17411321                          -0.8243381
## [2,]                         -0.13564882                          -0.7139759
## [3,]                         -0.12663168                          -0.7033283
## [4,]                         -0.14466585                          -0.7000657
## [5,]                         -0.01801079                          -0.6225664
## [6,]                         -0.08154657                          -0.5654481
##      logSigma1p0_firstorder_Energy logSigma1p0_firstorder_Entropy
## [1,]                    -0.8666076                      -1.990067
## [2,]                    -0.8497408                      -1.776760
## [3,]                    -0.8420813                      -1.745674
## [4,]                    -0.8530705                      -1.599917
## [5,]                    -0.8493681                      -2.151389
## [6,]                    -0.8252414                      -1.431336
##      logSigma1p0_firstorder_InterquartileRange logSigma1p0_firstorder_Kurtosis
## [1,]                                 -1.351706                      -0.5064040
## [2,]                                 -1.365690                      -0.1950605
## [3,]                                 -1.325516                      -0.2194418
## [4,]                                 -1.189437                      -0.5641903
## [5,]                                 -1.430708                       1.0717229
## [6,]                                 -1.326193                       0.2356137
##      logSigma1p0_firstorder_Maximum
## [1,]                     -1.0687969
## [2,]                     -0.9748419
## [3,]                     -0.9748419
## [4,]                     -0.9748419
## [5,]                     -0.8362133
## [6,]                     -0.7749968
##      logSigma1p0_firstorder_MeanAbsoluteDeviation logSigma1p0_firstorder_Mean
## [1,]                                    -1.375269                  -0.5011797
## [2,]                                    -1.256394                  -0.4126302
## [3,]                                    -1.268420                  -0.4170676
## [4,]                                    -1.235489                  -0.4338701
## [5,]                                    -1.315893                  -0.3429109
## [6,]                                    -1.184390                  -0.3392545
##      logSigma1p0_firstorder_Median logSigma1p0_firstorder_Minimum
## [1,]                    -0.4611420                     0.09551689
## [2,]                    -0.3753121                     0.09551689
## [3,]                    -0.3874371                     0.09551689
## [4,]                    -0.4091348                     0.09551689
## [5,]                    -0.3135494                     0.09551689
## [6,]                    -0.3135494                     0.09551689
##      logSigma1p0_firstorder_Range
## [1,]                    -1.675206
## [2,]                    -1.537826
## [3,]                    -1.537826
## [4,]                    -1.537826
## [5,]                    -1.335124
## [6,]                    -1.245614
##      logSigma1p0_firstorder_RobustMeanAbsoluteDeviation
## [1,]                                          -1.344053
## [2,]                                          -1.320394
## [3,]                                          -1.298347
## [4,]                                          -1.326554
## [5,]                                          -1.505170
## [6,]                                          -1.242709
##      logSigma1p0_firstorder_RootMeanSquared logSigma1p0_firstorder_Skewness
## [1,]                            -0.00172138                      -0.9993230
## [2,]                            -0.14583214                      -1.3577427
## [3,]                            -0.13919551                      -1.1740491
## [4,]                            -0.10883168                      -0.7628381
## [5,]                            -0.26201007                      -1.1894790
## [6,]                            -0.26163663                      -0.6554735
##      logSigma1p0_firstorder_TotalEnergy logSigma1p0_firstorder_Uniformity
## [1,]                         -0.8666076                          1.967254
## [2,]                         -0.8497408                          2.129166
## [3,]                         -0.8420813                          1.957578
## [4,]                         -0.8530705                          1.543939
## [5,]                         -0.8493681                          3.354372
## [6,]                         -0.8252414                          1.777384
##      logSigma1p0_firstorder_Variance logSigma1p0_glcm_Autocorrelation
## [1,]                      -0.9825594                       -0.9143732
## [2,]                      -0.9380960                       -0.8535464
## [3,]                      -0.9439750                       -0.8583337
## [4,]                      -0.9315891                       -0.8677306
## [5,]                      -0.9261334                       -0.8158723
## [6,]                      -0.8859624                       -0.8161809
##      logSigma1p0_glcm_ClusterProminence logSigma1p0_glcm_ClusterShade
## [1,]                         -0.4843536                    0.05860954
## [2,]                         -0.4817726                    0.02816378
## [3,]                         -0.4823216                    0.03862994
## [4,]                         -0.4821943                    0.04736833
## [5,]                         -0.4838613                    0.04299452
## [6,]                         -0.4779734                    0.03944552
##      logSigma1p0_glcm_ClusterTendency logSigma1p0_glcm_Contrast
## [1,]                       -0.9399337                -0.7803485
## [2,]                       -0.8992662                -0.8682278
## [3,]                       -0.9012241                -0.7979243
## [4,]                       -0.8916711                -0.7375501
## [5,]                       -0.9627971                -1.0109653
## [6,]                       -0.8712001                -0.8822394
##      logSigma1p0_glcm_Correlation logSigma1p0_glcm_DifferenceAverage
## [1,]                   -3.3381875                         -0.8141338
## [2,]                   -1.5496850                         -1.2109264
## [3,]                   -2.2046281                         -0.9896845
## [4,]                   -2.4296260                         -0.8012509
## [5,]                   -1.5732778                         -1.6389815
## [6,]                   -0.6666584                         -1.2830705
##      logSigma1p0_glcm_DifferenceEntropy logSigma1p0_glcm_DifferenceVariance
## [1,]                         -2.2430110                          -1.1923257
## [2,]                         -0.5738460                          -0.6146650
## [3,]                         -0.4218125                          -0.5572096
## [4,]                         -0.4909212                          -0.6084912
## [5,]                         -1.7372688                          -1.0841984
## [6,]                         -0.3964948                          -0.4619221
##      logSigma1p0_glcm_Id logSigma1p0_glcm_Idm logSigma1p0_glcm_Idmn
## [1,]           0.5466312            0.6997826             0.7880310
## [2,]           1.5785027            1.5307500             0.8781843
## [3,]           1.0865398            1.1077119             0.8061770
## [4,]           0.6694731            0.7483455             0.7443596
## [5,]           2.5040605            2.3365363             1.0243484
## [6,]           1.7738127            1.6855535             0.8925600
##      logSigma1p0_glcm_Idn logSigma1p0_glcm_Imc1 logSigma1p0_glcm_Imc2
## [1,]            0.8121496            0.17733538            -0.9463782
## [2,]            1.2485043            0.49693839            -1.1880841
## [3,]            1.0083147            0.78585391            -0.9044529
## [4,]            0.8038177            0.70947442            -0.6996869
## [5,]            1.7122299            0.71647239            -2.6070884
## [6,]            1.3281283            0.04087937            -0.4122273
##      logSigma1p0_glcm_InverseVariance logSigma1p0_glcm_JointEnergy
## [1,]                        2.5550291                    1.7580809
## [2,]                       -0.2743633                    2.0865535
## [3,]                        0.7030634                    1.2452170
## [4,]                        1.5215659                    0.7915671
## [5,]                       -1.9762859                    5.4565247
## [6,]                       -0.8441992                    2.4128732
##      logSigma1p0_glcm_JointEntropy logSigma1p0_glcm_MaximumProbability
## [1,]                     -2.035364                            1.142242
## [2,]                     -1.892021                            2.473540
## [3,]                     -1.551459                            1.501693
## [4,]                     -1.384439                            0.486102
## [5,]                     -2.884021                            5.042947
## [6,]                     -1.772735                            3.099251
##      logSigma1p0_glcm_SumAverage logSigma1p0_glcm_SumEntropy
## [1,]                  -0.9029349                   -2.302456
## [2,]                  -0.8093413                   -1.943749
## [3,]                  -0.8161832                   -1.761407
## [4,]                  -0.8305958                   -1.660747
## [5,]                  -0.7515068                   -2.787310
## [6,]                  -0.7542476                   -1.701712
##      logSigma1p0_glcm_SumSquares logSigma1p0_glszm_GrayLevelNonUniformity
## [1,]                  -0.9336461                               -1.3455362
## [2,]                  -0.9121144                               -1.3455362
## [3,]                  -0.9029048                               -0.6712969
## [4,]                  -0.8852830                               -0.6712969
## [5,]                  -0.9891760                               -0.6712969
## [6,]                  -0.8900223                               -0.7836700
##      logSigma1p0_glszm_GrayLevelNonUniformityNormalized
## [1,]                                           2.958392
## [2,]                                           1.665177
## [3,]                                           2.130734
## [4,]                                           2.130734
## [5,]                                           2.130734
## [6,]                                           1.234105
##      logSigma1p0_glszm_GrayLevelVariance
## [1,]                          -1.1937056
## [2,]                          -1.0936836
## [3,]                          -1.1296916
## [4,]                          -1.1296916
## [5,]                          -1.0748223
## [6,]                          -0.9984246
##      logSigma1p0_glszm_HighGrayLevelZoneEmphasis
## [1,]                                  -0.9899108
## [2,]                                  -0.9184321
## [3,]                                  -0.9060748
## [4,]                                  -0.9060748
## [5,]                                  -0.8755450
## [6,]                                  -0.8190890
##      logSigma1p0_glszm_LargeAreaEmphasis
## [1,]                          -0.8117074
## [2,]                          -0.7765199
## [3,]                          -0.8005245
## [4,]                          -0.8236616
## [5,]                          -0.7438388
## [6,]                          -0.7529008
##      logSigma1p0_glszm_LargeAreaHighGrayLevelEmphasis
## [1,]                                       -0.7329271
## [2,]                                       -0.7160119
## [3,]                                       -0.7265665
## [4,]                                       -0.7364560
## [5,]                                       -0.7005720
## [6,]                                       -0.7047832
##      logSigma1p0_glszm_LargeAreaLowGrayLevelEmphasis
## [1,]                                      -0.1547854
## [2,]                                      -0.1523449
## [3,]                                      -0.1542629
## [4,]                                      -0.1561661
## [5,]                                      -0.1500449
## [6,]                                      -0.1506473
##      logSigma1p0_glszm_LowGrayLevelZoneEmphasis
## [1,]                                -0.01975159
## [2,]                                -0.06452644
## [3,]                                -0.07723814
## [4,]                                -0.07723814
## [5,]                                -0.09139131
## [6,]                                -0.11827177
##      logSigma1p0_glszm_SizeZoneNonUniformity
## [1,]                              -0.7156517
## [2,]                              -0.7156517
## [3,]                              -0.5870438
## [4,]                              -0.4584359
## [5,]                              -0.3298280
## [6,]                              -0.5013052
##      logSigma1p0_glszm_SizeZoneNonUniformityNormalized
## [1,]                                         1.5237422
## [2,]                                         0.5648844
## [3,]                                         0.9100732
## [4,]                                         1.8305767
## [5,]                                         2.7510801
## [6,]                                         0.8845039
##      logSigma1p0_glszm_SmallAreaEmphasis
## [1,]                          -0.9706560
## [2,]                           0.2428486
## [3,]                           0.9719621
## [4,]                           1.0132359
## [5,]                           2.0652214
## [6,]                           0.7865054
##      logSigma1p0_glszm_SmallAreaHighGrayLevelEmphasis
## [1,]                                       -0.9353081
## [2,]                                       -0.4707567
## [3,]                                       -0.2594234
## [4,]                                       -0.2471504
## [5,]                                        0.0318650
## [6,]                                       -0.1785931
##      logSigma1p0_glszm_SmallAreaLowGrayLevelEmphasis
## [1,]                                    -0.224032879
## [2,]                                    -0.043522271
## [3,]                                     0.101102070
## [4,]                                     0.109420361
## [5,]                                     0.391462340
## [6,]                                    -0.002931533
##      logSigma1p0_glszm_ZoneEntropy logSigma1p0_glszm_ZonePercentage
## [1,]                     -2.880805                         1.515439
## [2,]                     -2.267634                         1.276645
## [3,]                     -1.792021                         1.737176
## [4,]                     -1.792021                         2.291519
## [5,]                     -2.382976                         1.515439
## [6,]                     -1.403417                         1.352053
##      logSigma1p0_glszm_ZoneVariance logSigma1p0_ngtdm_Busyness
## [1,]                     -0.7965114                 0.06080964
## [2,]                     -0.7420525                -0.29292714
## [3,]                     -0.7592485                -0.25685882
## [4,]                     -0.7823772                -0.23442215
## [5,]                     -0.6551691                -0.30982251
## [6,]                     -0.6864224                -0.30181485
##      logSigma1p0_ngtdm_Coarseness logSigma1p0_ngtdm_Complexity
## [1,]                 -0.008547759                   -0.7773855
## [2,]                 -0.008524931                   -0.7643678
## [3,]                 -0.008548094                   -0.7590027
## [4,]                 -0.008542473                   -0.7532052
## [5,]                 -0.008533936                   -0.7761877
## [6,]                 -0.008548405                   -0.7398146
##      logSigma1p0_ngtdm_Contrast logSigma1p0_ngtdm_Strength
## [1,]                  0.3946809                 -0.7752940
## [2,]                 -0.5537464                 -0.4597743
## [3,]                 -0.5061574                 -0.5693955
## [4,]                 -0.2961292                 -0.5214209
## [5,]                 -1.0051184                 -0.3378473
## [6,]                 -0.8075426                 -0.2016870
##      logSigma1p0_gldm_DependenceEntropy
## [1,]                          -6.687609
## [2,]                          -5.105869
## [3,]                          -5.754723
## [4,]                          -6.353683
## [5,]                          -5.651590
## [6,]                          -4.463398
##      logSigma1p0_gldm_DependenceNonUniformity
## [1,]                                -1.414345
## [2,]                                -1.793538
## [3,]                                -1.700432
## [4,]                                -1.671090
## [5,]                                -1.763518
## [6,]                                -1.625146
##      logSigma1p0_gldm_DependenceNonUniformityNormalized
## [1,]                                          5.6801159
## [2,]                                          0.5638024
## [3,]                                          0.9787930
## [4,]                                          1.7355130
## [5,]                                          0.3785693
## [6,]                                          0.5051462
##      logSigma1p0_gldm_DependenceVariance
## [1,]                          -1.0686296
## [2,]                          -0.7187601
## [3,]                          -0.7409530
## [4,]                          -0.9187277
## [5,]                          -0.3184542
## [6,]                          -0.4192857
##      logSigma1p0_gldm_GrayLevelNonUniformity logSigma1p0_gldm_GrayLevelVariance
## [1,]                               -1.570151                         -0.9588224
## [2,]                               -1.374107                         -0.9266373
## [3,]                               -1.355534                         -0.9327113
## [4,]                               -1.496376                         -0.9202724
## [5,]                               -1.081899                         -0.9641569
## [6,]                               -1.177629                         -0.8829980
##      logSigma1p0_gldm_HighGrayLevelEmphasis
## [1,]                             -0.9227837
## [2,]                             -0.8698697
## [3,]                             -0.8748363
## [4,]                             -0.8846684
## [5,]                             -0.8297172
## [6,]                             -0.8233739
##      logSigma1p0_gldm_LargeDependenceEmphasis
## [1,]                               -1.1293582
## [2,]                               -0.8219342
## [3,]                               -0.8999960
## [4,]                               -1.0369533
## [5,]                               -0.5333465
## [6,]                               -0.6563909
##      logSigma1p0_gldm_LargeDependenceHighGrayLevelEmphasis
## [1,]                                            -0.8974650
## [2,]                                            -0.7867168
## [3,]                                            -0.8146514
## [4,]                                            -0.8628651
## [5,]                                            -0.6831490
## [6,]                                            -0.7267060
##      logSigma1p0_gldm_LargeDependenceLowGrayLevelEmphasis
## [1,]                                           -0.1776673
## [2,]                                           -0.1613465
## [3,]                                           -0.1655525
## [4,]                                           -0.1730498
## [5,]                                           -0.1460158
## [6,]                                           -0.1525607
##      logSigma1p0_gldm_LowGrayLevelEmphasis
## [1,]                           -0.07906168
## [2,]                           -0.10516709
## [3,]                           -0.10320519
## [4,]                           -0.09744371
## [5,]                           -0.12608660
## [6,]                           -0.12426129
##      logSigma1p0_gldm_SmallDependenceEmphasis
## [1,]                                0.8319455
## [2,]                                0.6909995
## [3,]                                1.3668911
## [4,]                                1.7809245
## [5,]                                1.4348805
## [6,]                                0.8975777
##      logSigma1p0_gldm_SmallDependenceHighGrayLevelEmphasis
## [1,]                                           -0.40897862
## [2,]                                           -0.35327091
## [3,]                                           -0.14319991
## [4,]                                           -0.01676697
## [5,]                                           -0.10304812
## [6,]                                           -0.18014459
##      logSigma1p0_gldm_SmallDependenceLowGrayLevelEmphasis
## [1,]                                            0.3167900
## [2,]                                            0.1770992
## [3,]                                            0.3746168
## [4,]                                            0.5052596
## [5,]                                            0.4019920
## [6,]                                            0.1510680

Outliers

# Find IQR outliers for each radiomic feature
outlier_summary <- lapply(
  colnames(feature_z),
  function(feature_name) {

    x <- feature_z[, feature_name]

    q1 <- quantile(x, 0.25)
    q3 <- quantile(x, 0.75)
    iqr <- q3 - q1

    lower <- q1 - 1.5 * iqr
    upper <- q3 + 1.5 * iqr

    is_outlier <- x < lower | x > upper

    data.frame(
      feature = feature_name,
      n_outliers = sum(is_outlier),
      percent_outliers = 100 * mean(is_outlier),
      min_z = min(x),
      max_z = max(x)
    )
  }
)

outlier_summary <- bind_rows(outlier_summary)

cat("Features assessed:", nrow(outlier_summary), "\n")
## Features assessed: 273
cat(
  "Median % outliers per feature:",
  median(outlier_summary$percent_outliers),
  "\n"
)
## Median % outliers per feature: 2.474068
cat(
  "Maximum % outliers in a feature:",
  max(outlier_summary$percent_outliers),
  "\n"
)
## Maximum % outliers in a feature: 20.07156
outlier_summary |>
  arrange(desc(percent_outliers)) |>
  slice_head(n = 10)
##                                                 feature n_outliers
## 1                         logSigma1p0_glcm_ClusterShade      21653
## 2                         logSigma0p5_glcm_ClusterShade      15291
## 3             logSigma1p0_glrlm_LowGrayLevelRunEmphasis      13992
## 4        logSigma1p0_glrlm_ShortRunLowGrayLevelEmphasis      13965
## 5  logSigma1p0_gldm_LargeDependenceLowGrayLevelEmphasis      13632
## 6         logSigma1p0_glrlm_LongRunLowGrayLevelEmphasis      13626
## 7                    logSigma1p0_glcm_ClusterProminence      12888
## 8       logSigma1p0_glszm_LargeAreaLowGrayLevelEmphasis      12549
## 9                            original_glcm_ClusterShade      12530
## 10                logSigma1p0_gldm_LowGrayLevelEmphasis      12220
##    percent_outliers       min_z    max_z
## 1          20.07156 -12.2563159 13.42948
## 2          14.17421 -18.4560890 14.96087
## 3          12.97009  -0.4153115 13.88723
## 4          12.94506  -0.4527320 14.49125
## 5          12.63638  -0.1906242 39.98686
## 6          12.63082  -0.3441881 23.31752
## 7          11.94672  -0.4851412 12.97924
## 8          11.63248  -0.1602284 83.29698
## 9          11.61486 -15.0182195 16.38647
## 10         11.32751  -0.3663328 22.22302

#PCA

# Run PCA on the Z-scored radiomic features
pca <- prcomp(
  feature_z,
  center = FALSE,
  scale. = FALSE
)


summary(pca)
## Importance of components:
##                           PC1    PC2    PC3    PC4    PC5     PC6     PC7
## Standard deviation     7.5295 6.9408 5.6212 5.0060 3.7678 2.84662 2.77848
## Proportion of Variance 0.2077 0.1765 0.1157 0.0918 0.0520 0.02968 0.02828
## Cumulative Proportion  0.2077 0.3841 0.4999 0.5917 0.6437 0.67335 0.70163
##                            PC8     PC9    PC10    PC11    PC12    PC13    PC14
## Standard deviation     2.42231 2.28014 2.16779 1.99114 1.84209 1.68982 1.58286
## Proportion of Variance 0.02149 0.01904 0.01721 0.01452 0.01243 0.01046 0.00918
## Cumulative Proportion  0.72312 0.74217 0.75938 0.77390 0.78633 0.79679 0.80597
##                           PC15    PC16    PC17    PC18    PC19   PC20    PC21
## Standard deviation     1.56343 1.55377 1.51598 1.46539 1.38079 1.3111 1.29165
## Proportion of Variance 0.00895 0.00884 0.00842 0.00787 0.00698 0.0063 0.00611
## Cumulative Proportion  0.81492 0.82377 0.83219 0.84005 0.84704 0.8533 0.85944
##                           PC22    PC23    PC24    PC25    PC26    PC27    PC28
## Standard deviation     1.24570 1.21614 1.20073 1.16749 1.14215 1.09819 1.09039
## Proportion of Variance 0.00568 0.00542 0.00528 0.00499 0.00478 0.00442 0.00436
## Cumulative Proportion  0.86513 0.87054 0.87583 0.88082 0.88560 0.89001 0.89437
##                           PC29    PC30    PC31    PC32    PC33    PC34    PC35
## Standard deviation     1.07804 1.04659 1.03847 1.01450 1.00618 0.99662 0.95663
## Proportion of Variance 0.00426 0.00401 0.00395 0.00377 0.00371 0.00364 0.00335
## Cumulative Proportion  0.89863 0.90264 0.90659 0.91036 0.91407 0.91771 0.92106
##                           PC36    PC37    PC38    PC39    PC40    PC41    PC42
## Standard deviation     0.93063 0.91427 0.89127 0.87563 0.84914 0.83826 0.79569
## Proportion of Variance 0.00317 0.00306 0.00291 0.00281 0.00264 0.00257 0.00232
## Cumulative Proportion  0.92423 0.92729 0.93020 0.93301 0.93565 0.93823 0.94055
##                          PC43    PC44    PC45    PC46    PC47    PC48    PC49
## Standard deviation     0.7929 0.78002 0.75842 0.73263 0.71256 0.70518 0.67591
## Proportion of Variance 0.0023 0.00223 0.00211 0.00197 0.00186 0.00182 0.00167
## Cumulative Proportion  0.9428 0.94508 0.94718 0.94915 0.95101 0.95283 0.95450
##                           PC50    PC51    PC52    PC53   PC54    PC55    PC56
## Standard deviation     0.67035 0.63685 0.62465 0.61525 0.5957 0.59093 0.57616
## Proportion of Variance 0.00165 0.00149 0.00143 0.00139 0.0013 0.00128 0.00122
## Cumulative Proportion  0.95615 0.95764 0.95907 0.96045 0.9617 0.96303 0.96425
##                           PC57    PC58    PC59   PC60    PC61    PC62    PC63
## Standard deviation     0.55519 0.54958 0.53465 0.5235 0.51800 0.51333 0.50476
## Proportion of Variance 0.00113 0.00111 0.00105 0.0010 0.00098 0.00097 0.00093
## Cumulative Proportion  0.96538 0.96648 0.96753 0.9685 0.96952 0.97048 0.97141
##                          PC64    PC65    PC66    PC67    PC68    PC69    PC70
## Standard deviation     0.4963 0.48924 0.48059 0.46574 0.45957 0.45085 0.44786
## Proportion of Variance 0.0009 0.00088 0.00085 0.00079 0.00077 0.00074 0.00073
## Cumulative Proportion  0.9723 0.97319 0.97404 0.97483 0.97561 0.97635 0.97709
##                           PC71    PC72    PC73    PC74   PC75    PC76    PC77
## Standard deviation     0.43250 0.42339 0.41729 0.41201 0.4048 0.39957 0.38821
## Proportion of Variance 0.00069 0.00066 0.00064 0.00062 0.0006 0.00058 0.00055
## Cumulative Proportion  0.97777 0.97843 0.97907 0.97969 0.9803 0.98087 0.98143
##                           PC78    PC79   PC80    PC81    PC82    PC83    PC84
## Standard deviation     0.38595 0.38053 0.3689 0.35997 0.35812 0.35454 0.34942
## Proportion of Variance 0.00055 0.00053 0.0005 0.00047 0.00047 0.00046 0.00045
## Cumulative Proportion  0.98197 0.98250 0.9830 0.98348 0.98394 0.98441 0.98485
##                           PC85    PC86   PC87    PC88    PC89    PC90    PC91
## Standard deviation     0.34473 0.33767 0.3301 0.32175 0.31932 0.31876 0.31287
## Proportion of Variance 0.00044 0.00042 0.0004 0.00038 0.00037 0.00037 0.00036
## Cumulative Proportion  0.98529 0.98571 0.9861 0.98648 0.98686 0.98723 0.98759
##                           PC92    PC93    PC94    PC95    PC96   PC97   PC98
## Standard deviation     0.30687 0.30350 0.30064 0.29384 0.29185 0.2853 0.2842
## Proportion of Variance 0.00034 0.00034 0.00033 0.00032 0.00031 0.0003 0.0003
## Cumulative Proportion  0.98793 0.98827 0.98860 0.98892 0.98923 0.9895 0.9898
##                           PC99   PC100   PC101   PC102   PC103   PC104   PC105
## Standard deviation     0.28284 0.27986 0.27548 0.27431 0.27104 0.26305 0.25930
## Proportion of Variance 0.00029 0.00029 0.00028 0.00028 0.00027 0.00025 0.00025
## Cumulative Proportion  0.99012 0.99040 0.99068 0.99096 0.99123 0.99148 0.99173
##                          PC106   PC107   PC108   PC109   PC110   PC111   PC112
## Standard deviation     0.25557 0.25387 0.24915 0.24557 0.23943 0.23843 0.23678
## Proportion of Variance 0.00024 0.00024 0.00023 0.00022 0.00021 0.00021 0.00021
## Cumulative Proportion  0.99197 0.99220 0.99243 0.99265 0.99286 0.99307 0.99327
##                         PC113   PC114   PC115   PC116   PC117   PC118   PC119
## Standard deviation     0.2346 0.23044 0.22681 0.22291 0.21996 0.21784 0.21618
## Proportion of Variance 0.0002 0.00019 0.00019 0.00018 0.00018 0.00017 0.00017
## Cumulative Proportion  0.9935 0.99367 0.99386 0.99404 0.99422 0.99439 0.99456
##                          PC120   PC121   PC122   PC123   PC124   PC125   PC126
## Standard deviation     0.21148 0.20954 0.20671 0.19862 0.19687 0.19498 0.19373
## Proportion of Variance 0.00016 0.00016 0.00016 0.00014 0.00014 0.00014 0.00014
## Cumulative Proportion  0.99473 0.99489 0.99504 0.99519 0.99533 0.99547 0.99561
##                          PC127   PC128   PC129   PC130   PC131   PC132   PC133
## Standard deviation     0.18561 0.18489 0.18347 0.18268 0.17668 0.17436 0.17214
## Proportion of Variance 0.00013 0.00013 0.00012 0.00012 0.00011 0.00011 0.00011
## Cumulative Proportion  0.99573 0.99586 0.99598 0.99610 0.99622 0.99633 0.99644
##                          PC134  PC135  PC136  PC137  PC138   PC139   PC140
## Standard deviation     0.17106 0.1692 0.1665 0.1637 0.1613 0.15955 0.15621
## Proportion of Variance 0.00011 0.0001 0.0001 0.0001 0.0001 0.00009 0.00009
## Cumulative Proportion  0.99655 0.9967 0.9968 0.9969 0.9969 0.99704 0.99713
##                          PC141   PC142   PC143   PC144   PC145   PC146   PC147
## Standard deviation     0.15342 0.15243 0.15159 0.14955 0.14666 0.14456 0.14180
## Proportion of Variance 0.00009 0.00009 0.00008 0.00008 0.00008 0.00008 0.00007
## Cumulative Proportion  0.99721 0.99730 0.99738 0.99746 0.99754 0.99762 0.99769
##                          PC148   PC149   PC150   PC151   PC152   PC153   PC154
## Standard deviation     0.14064 0.14052 0.13576 0.13536 0.13423 0.13245 0.13073
## Proportion of Variance 0.00007 0.00007 0.00007 0.00007 0.00007 0.00006 0.00006
## Cumulative Proportion  0.99777 0.99784 0.99791 0.99797 0.99804 0.99810 0.99817
##                          PC155   PC156   PC157   PC158   PC159   PC160   PC161
## Standard deviation     0.12934 0.12639 0.12304 0.12063 0.11836 0.11805 0.11668
## Proportion of Variance 0.00006 0.00006 0.00006 0.00005 0.00005 0.00005 0.00005
## Cumulative Proportion  0.99823 0.99829 0.99834 0.99839 0.99845 0.99850 0.99855
##                          PC162   PC163   PC164   PC165   PC166   PC167   PC168
## Standard deviation     0.11418 0.11323 0.11219 0.10958 0.10783 0.10712 0.10567
## Proportion of Variance 0.00005 0.00005 0.00005 0.00004 0.00004 0.00004 0.00004
## Cumulative Proportion  0.99859 0.99864 0.99869 0.99873 0.99877 0.99882 0.99886
##                          PC169   PC170   PC171   PC172   PC173   PC174   PC175
## Standard deviation     0.10369 0.10294 0.10179 0.10083 0.09842 0.09722 0.09670
## Proportion of Variance 0.00004 0.00004 0.00004 0.00004 0.00004 0.00003 0.00003
## Cumulative Proportion  0.99890 0.99894 0.99897 0.99901 0.99905 0.99908 0.99912
##                          PC176   PC177   PC178   PC179   PC180   PC181   PC182
## Standard deviation     0.09583 0.09404 0.09236 0.09068 0.08983 0.08851 0.08750
## Proportion of Variance 0.00003 0.00003 0.00003 0.00003 0.00003 0.00003 0.00003
## Cumulative Proportion  0.99915 0.99918 0.99921 0.99924 0.99927 0.99930 0.99933
##                          PC183   PC184   PC185   PC186   PC187   PC188   PC189
## Standard deviation     0.08585 0.08564 0.08287 0.08240 0.08060 0.07874 0.07834
## Proportion of Variance 0.00003 0.00003 0.00003 0.00002 0.00002 0.00002 0.00002
## Cumulative Proportion  0.99936 0.99938 0.99941 0.99943 0.99946 0.99948 0.99950
##                          PC190   PC191   PC192   PC193   PC194   PC195   PC196
## Standard deviation     0.07777 0.07661 0.07435 0.07324 0.07167 0.07064 0.06979
## Proportion of Variance 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002 0.00002
## Cumulative Proportion  0.99952 0.99955 0.99957 0.99959 0.99960 0.99962 0.99964
##                          PC197   PC198   PC199   PC200   PC201   PC202   PC203
## Standard deviation     0.06954 0.06819 0.06712 0.06471 0.06268 0.06154 0.05975
## Proportion of Variance 0.00002 0.00002 0.00002 0.00002 0.00001 0.00001 0.00001
## Cumulative Proportion  0.99966 0.99967 0.99969 0.99971 0.99972 0.99973 0.99975
##                          PC204   PC205   PC206   PC207   PC208   PC209   PC210
## Standard deviation     0.05948 0.05765 0.05750 0.05636 0.05385 0.05371 0.05294
## Proportion of Variance 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
## Cumulative Proportion  0.99976 0.99977 0.99979 0.99980 0.99981 0.99982 0.99983
##                          PC211   PC212   PC213   PC214   PC215   PC216   PC217
## Standard deviation     0.05266 0.05160 0.04890 0.04837 0.04751 0.04564 0.04517
## Proportion of Variance 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
## Cumulative Proportion  0.99984 0.99985 0.99986 0.99987 0.99987 0.99988 0.99989
##                          PC218   PC219   PC220   PC221   PC222   PC223   PC224
## Standard deviation     0.04409 0.04375 0.04240 0.04119 0.04103 0.03960 0.03936
## Proportion of Variance 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001 0.00001
## Cumulative Proportion  0.99990 0.99990 0.99991 0.99992 0.99992 0.99993 0.99993
##                          PC225  PC226   PC227   PC228   PC229   PC230   PC231
## Standard deviation     0.03758 0.0357 0.03505 0.03411 0.03394 0.03322 0.03278
## Proportion of Variance 0.00001 0.0000 0.00000 0.00000 0.00000 0.00000 0.00000
## Cumulative Proportion  0.99994 0.9999 0.99995 0.99995 0.99996 0.99996 0.99996
##                          PC232  PC233   PC234   PC235   PC236   PC237   PC238
## Standard deviation     0.03113 0.0294 0.02924 0.02792 0.02697 0.02618 0.02595
## Proportion of Variance 0.00000 0.0000 0.00000 0.00000 0.00000 0.00000 0.00000
## Cumulative Proportion  0.99997 1.0000 0.99997 0.99998 0.99998 0.99998 0.99998
##                         PC239 PC240  PC241   PC242   PC243   PC244   PC245
## Standard deviation     0.0254 0.025 0.0238 0.01943 0.01905 0.01874 0.01751
## Proportion of Variance 0.0000 0.000 0.0000 0.00000 0.00000 0.00000 0.00000
## Cumulative Proportion  1.0000 1.000 1.0000 0.99999 0.99999 1.00000 1.00000
##                          PC246   PC247   PC248    PC249    PC250    PC251
## Standard deviation     0.01724 0.01672 0.01048 0.009813 0.008335 0.006642
## Proportion of Variance 0.00000 0.00000 0.00000 0.000000 0.000000 0.000000
## Cumulative Proportion  1.00000 1.00000 1.00000 1.000000 1.000000 1.000000
##                           PC252    PC253    PC254    PC255    PC256    PC257
## Standard deviation     0.004366 0.003142 0.002764 0.002526 0.001816 0.001376
## Proportion of Variance 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
## Cumulative Proportion  1.000000 1.000000 1.000000 1.000000 1.000000 1.000000
##                            PC258    PC259     PC260     PC261     PC262
## Standard deviation     0.0008922 0.000435 0.0003066 0.0002027 5.364e-05
## Proportion of Variance 0.0000000 0.000000 0.0000000 0.0000000 0.000e+00
## Cumulative Proportion  1.0000000 1.000000 1.0000000 1.0000000 1.000e+00
##                            PC263     PC264     PC265     PC266     PC267
## Standard deviation     3.121e-05 8.145e-06 1.184e-07 7.786e-08 6.981e-08
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
##                            PC268     PC269     PC270     PC271     PC272
## Standard deviation     6.118e-08 5.232e-08 4.577e-08 4.461e-08 2.895e-08
## Proportion of Variance 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00
## Cumulative Proportion  1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00
##                            PC273
## Standard deviation     2.492e-08
## Proportion of Variance 0.000e+00
## Cumulative Proportion  1.000e+00
# Variance explained by each principal component (variance/total variance)
variance_explained <- pca$sdev^2 / sum(pca$sdev^2)

# Cumulative variance explained
cumulative_variance <- cumsum(variance_explained)

# Find the first PC where cumulative variance reaches 90%
n_pcs_90 <- which(cumulative_variance >= 0.90)[1]

cat("Total original features:", ncol(feature_z), "\n")
## Total original features: 273
cat("PCs needed to explain 90% variance:", n_pcs_90, "\n")
## PCs needed to explain 90% variance: 30
cat(
  "Cumulative variance explained:",
  round(cumulative_variance[n_pcs_90] * 100, 2),
  "%\n"
)
## Cumulative variance explained: 90.26 %
#???? Second opinion needed on this graph
# Create PCA variance table
pca_variance <- data.frame(
  PC = seq_along(variance_explained),
  variance_explained = variance_explained,
  cumulative_variance = cumulative_variance
)

# Plot cumulative variance explained
ggplot(
  pca_variance,
  aes(x = PC, y = cumulative_variance)
) +
  geom_line() +
  geom_point(size = 1) +
  geom_hline(
    yintercept = 0.90,
    linetype = "dashed"
  ) +
  geom_vline(
    xintercept = n_pcs_90,
    linetype = "dashed"
  ) +
  labs(
    title = "PCA cumulative variance — Lüsebrink Left",
    x = "Principal component",
    y = "Cumulative variance explained"
  ) +
  theme_minimal()

# Create scree plot data
pca_variance <- data.frame(
  PC = seq_along(variance_explained),
  variance_explained = variance_explained
)

# Scree plot
ggplot(
  pca_variance,
  aes(x = PC, y = variance_explained)
) +
  geom_col(fill = "steelblue") +
  geom_line() +
  geom_point() +
  labs(
    title = "Scree Plot — Lüsebrink Left",
    x = "Principal Components",
    y = "Proportion of Variance Explained"
  ) +
  theme_minimal()