View source: R/nmr_data_analysis.R
plot_vip_scores | R Documentation |
Plot vip scores of bootstrap
plot_vip_scores(vip_means, error, nbootstrap, plot = TRUE)
vip_means |
vips means values of bootstraps |
error |
error tolerated, calculated in the bootstrap |
nbootstrap |
number of bootstraps realiced |
plot |
A boolean that indicate if results are plotted or not |
A plot of the results or a ggplot object
# Data analysis for a table of integrated peaks
## Generate an artificial nmr_dataset_peak_table:
### Generate artificial metadata:
num_samples <- 64 # use an even number in this example
num_peaks <- 20
metadata <- data.frame(
NMRExperiment = as.character(1:num_samples),
Condition = rep(c("A", "B"), times = num_samples / 2)
)
### The matrix with peaks
peak_means <- runif(n = num_peaks, min = 300, max = 600)
peak_sd <- runif(n = num_peaks, min = 30, max = 60)
peak_matrix <- mapply(function(mu, sd) rnorm(num_samples, mu, sd),
mu = peak_means, sd = peak_sd
)
colnames(peak_matrix) <- paste0("Peak", 1:num_peaks)
## Artificial differences depending on the condition:
peak_matrix[metadata$Condition == "A", "Peak2"] <-
peak_matrix[metadata$Condition == "A", "Peak2"] + 70
peak_matrix[metadata$Condition == "A", "Peak6"] <-
peak_matrix[metadata$Condition == "A", "Peak6"] - 60
### The nmr_dataset_peak_table
peak_table <- new_nmr_dataset_peak_table(
peak_table = peak_matrix,
metadata = list(external = metadata)
)
## We will use bootstrap and permutation method for VIPs selection
## in a a k-fold cross validation
# bp_results <- bp_kfold_VIP_analysis(peak_table, # Data to be analized
# y_column = "Condition", # Label
# k = 3,
# ncomp = 1,
# nbootstrap = 10)
# message("Selected VIPs are: ", bp_results$importarn_vips)
# plot_vip_scores(bp_results$kfold_results[[1]]$vip_means,
# bp_results$kfold_results[[1]]$error[1],
# nbootstrap = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.