## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE ) ## ----install-cran------------------------------------------------------------- # install.packages("easyLSEA") ## ----install-github----------------------------------------------------------- # # install.packages("remotes") # remotes::install_github("DavidGO464/easyLSEA") ## ----install-fgsea------------------------------------------------------------ # BiocManager::install("fgsea") ## ----quickstart--------------------------------------------------------------- # library(easyLSEA) # # result <- easyLSEA( # data = my_lipid_data, # lipid_col = "LipidName", # fc_col = "logFC", # pval_col = "P.Value", # case_lbl = "NASH", # ref_lbl = "Control", # engine = "both", # run KS and fgsea # min_rank = "E" # include all confidence ranks except P and NA (default) # ) ## ----meta--------------------------------------------------------------------- # result$meta$date # result$meta$case_lbl # result$meta$n_lipids ## ----lsea--------------------------------------------------------------------- # # KS results — one row per lipid set per grouping level # head(result$lsea$ks) # # # fgsea results # head(result$lsea$fgsea) # # # Combined table with Convergence column # head(result$lsea$combined) ## ----chains------------------------------------------------------------------- # # Long format — one row per acyl chain per lipid # head(result$chains$parsed) # # # Parsing status — one row per lipid # head(result$chains$summary) # # # Wide format — one row per lipid with sn positions and totals # head(result$chains$wide) ## ----plots-list--------------------------------------------------------------- # # List all available plots # names(result$plots$lsea) # names(result$plots$chains) ## ----input-------------------------------------------------------------------- # # Annotated data with LipidClass, LipidCategory_LMAPS, etc. # head(result$input$data) # # # Grouping columns tested # result$input$group_cols ## ----view-plots--------------------------------------------------------------- # # KS bubble plot — all lipid classes # result$plots$lsea$bubble_ks_01_Class # # # fgsea bubble plot — significant sets only # result$plots$lsea$bubble_fgsea_sig_01_Class # # # Distribution plot — lipid class level # result$plots$lsea$dist_01_Class ## ----bubble-label------------------------------------------------------------- # # Regenerate plots showing only FDR and n # plots <- plot_lsea( # result$lsea, # case_lbl = "NASH", # ref_lbl = "Control", # bubble_label = c("FDR", "n") # ) ## ----export------------------------------------------------------------------- # export_lsea( # result, # dir = tempdir(), # format = c("csv", "excel", "pdf") # ) ## ----advanced-separate-------------------------------------------------------- # # Step 1: annotate # annotated <- annotate_lipids(my_lipid_data, lipid_col = "LipidName") # # # Step 2: run enrichment # lsea_res <- run_lsea( # data = annotated, # fc_col = "logFC", # engine = "both", # case_lbl = "NASH", # ref_lbl = "Control" # ) # # # Step 3: generate plots manually # plots <- plot_lsea( # lsea_res, # case_lbl = "NASH", # ref_lbl = "Control", # fdr_thresh = 0.05, # bubble_label = c("FDR", "DS", "NES", "n") # ) # # # Step 4: distribution plot for a specific level # p_dist <- plot_distribution( # data = annotated, # lsea_result = lsea_res, # group_col = "LipidClass", # case_lbl = "NASH", # ref_lbl = "Control" # ) ## ----fgsea-rank--------------------------------------------------------------- # # Default: pi-value = sign(logFC) * -log10(P.Value) # # Combines effect size and statistical evidence # # # Alternative: logFC only # result_fc <- easyLSEA( # data = my_lipid_data, # engine = "fgsea", # fgsea_rank = "logFC" # ) # # # Alternative: LIMMA t-statistic (requires a 't' column) # result_t <- easyLSEA( # data = my_lipid_data, # engine = "fgsea", # fgsea_rank = "t_stat" # ) ## ----thresholds--------------------------------------------------------------- # result <- easyLSEA( # data = my_lipid_data, # min_n = 5L, # require at least 5 lipids per set # n_perm = 5000L, # more permutations for DS_perm_pval # fgsea_nperm = 20000L # more permutations for fgsea # ) ## ----min-rank----------------------------------------------------------------- # # Default: include all except P and NA # result_all <- easyLSEA(data = my_lipid_data, min_rank = "E") # # # Strict: include only high-confidence annotations (A and B) # result_strict <- easyLSEA(data = my_lipid_data, min_rank = "B") # # # Or apply directly to parse_lipid_chains # chains_strict <- parse_lipid_chains(annotated, min_rank = "B") # table(chains_strict$summary$status) ## ----session, eval = TRUE----------------------------------------------------- sessionInfo()