Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional analysis: PCA-Metadata analysis #52

Open
ChristinaSchmidt1 opened this issue Aug 14, 2023 · 0 comments
Open

Functional analysis: PCA-Metadata analysis #52

ChristinaSchmidt1 opened this issue Aug 14, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request Future Implementation will be done once priority issues are closed

Comments

@ChristinaSchmidt1
Copy link
Collaborator

ChristinaSchmidt1 commented Aug 14, 2023

Here we can perform PCA analysis (not plotting) and assign metadata such as age, gender,... as being significantly separated on a PC. Next we can extract the metabolites of this PC that are the separators.
The output will be a DF that the user can then use further (e.g. for plotting the results).

This is from the VizPCA function, which now does not produce a DF output anymore.

#Prepare output DF
  loading_data <- prcomp(as.matrix(Input_data_m, scale. = as.logical(Scaling)))
  loading_data_table <-as.data.frame(loading_data$rotation)
  loading_data_table <- loading_data_table
  loading_data_table <- tibble::rownames_to_column(loading_data_table, "Metabolite")

  # Save output
  if(OutputPlotName ==""){
    write.csv(loading_data_table, paste(Results_folder_plots_PCA_folder,"/Loadings.csv", sep=""))
  }else{
    write.csv(loading_data_table, paste(Results_folder_plots_PCA_folder,"/", OutputPlotName, "_Loadings.csv", sep=""))
  }

  if (Save_as_Results == "xlsx"){
    if(OutputPlotName ==""){
      xlsPCA <-  paste(Results_folder_plots_PCA_folder,"/Loadings.xlsx", sep="")
      writexl::write_xlsx(loading_data_table,xlsPCA, col_names = TRUE)
    }else{
      xlsPCA <-  paste(Results_folder_plots_PCA_folder,"/", OutputPlotName, "_Loadings.xlsx", sep="")
      writexl::write_xlsx(loading_data_table,xlsPCA, col_names = TRUE)
    }
  }else if (Save_as_Results == "csv"){
    if(OutputPlotName ==""){
      csvPCA <-  paste(Results_folder_plots_PCA_folder,"/Loadings.csv", sep="")
      write.csv(loading_data_table,csvPCA)
    }else{
      csvPCA <-  paste(Results_folder_plots_PCA_folder,"/", OutputPlotName, "_Loadings.csv", sep="")
      write.csv(loading_data_table,csvPCA)
    }
  }else if (Save_as_Results == "txt"){
    if(OutputPlotName ==""){
      txtPCA <-  paste(Results_folder_plots_PCA_folder,"/Loadings.txt", sep="")
      write.csv(loading_data_table,txtPCA)
    }else{
      txtPCA <-  paste(Results_folder_plots_PCA_folder,"/", OutputPlotName, "_Loadings.txt", sep="")
      write.csv(loading_data_table,txtPCA)
    }
  }
@ChristinaSchmidt1 ChristinaSchmidt1 self-assigned this Aug 14, 2023
@ChristinaSchmidt1 ChristinaSchmidt1 added the enhancement New feature or request label Aug 14, 2023
@ChristinaSchmidt1 ChristinaSchmidt1 added the Future Implementation will be done once priority issues are closed label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Future Implementation will be done once priority issues are closed
Projects
None yet
Development

No branches or pull requests

1 participant