R/PCA_prep.R

Defines functions PCA_prep

Documented in PCA_prep

#' PCA_prep
#' This function is meant to prepare the data before the PCA since all features need to be numeric
#' @return my_data_clean_PCA
#' @export
#'
#' @examples
PCA_prep <- function(){
  my_data_clean_PCA <- select(my_data_clean , patient_cohort,age,sex, diagnosis ,stage , plasma_CA19_9,creatinine , LYVE1, REG1B, TFF1) %>%
    mutate(patient_cohort = case_when(
      patient_cohort == "Cohort1" ~ 0,
      patient_cohort == "Cohort2" ~ 1),
      diagnosis = case_when(
        diagnosis == "control" ~ 0,
        diagnosis == "benign" ~ 1,
        diagnosis == "malignant" ~ 2),
      sex = case_when(
        sex == "Male" ~ 0,
        sex == "Female" ~ 1),
      stage = case_when(
        stage  == "IA" ~ 1,
        stage  == "IB" ~ 1,
        stage  == "IIA" ~ 2,
        stage  == "IIB" ~ 2,
        stage  == "III" ~ 3,
        stage  == "IV" ~ 4),
      stage = replace_na(stage,0)) %>%
    drop_na(REG1B, LYVE1, TFF1, plasma_CA19_9)
  return(my_data_clean_PCA)
}
rforbiodatascience22/PanRISK_package documentation built on April 24, 2022, 12:15 a.m.