Skip to contents

Downloads a consolidated expression matrix and clinical metadata for a TCGA or TARGET project and caches the result locally as an .rds file. Subsequent calls with the same arguments load from the cache instantly without re-downloading.

Usage

LoadTCGA(
  project,
  data_type = c("rnaseq", "microarray"),
  backend = c("recount3", "TCGAbiolinks"),
  cache_dir = NULL,
  force_reload = FALSE
)

Arguments

project

Character scalar. Project ID, e.g. "TCGA-GBM", "TCGA-LGG", "TARGET-NBL". See SurvPlot for the full list of available projects.

data_type

"rnaseq" (default) or "microarray". "microarray" forces backend = "TCGAbiolinks" automatically.

backend

Download engine. "recount3" (default) fetches a single pre-consolidated matrix — fast and reliable. "TCGAbiolinks" downloads one file per patient from the GDC API — use only when recount3 does not carry the project or for microarray data.

cache_dir

Directory for the cached .rds file. Defaults to the OS user cache directory for scSidekick.

force_reload

Logical (default FALSE). When TRUE, deletes the existing .rds cache file and re-downloads the dataset from scratch. Useful after adding TCGAbiolinks or when the upstream data have been updated. The new download is cached as usual.

Value

A named list with:

expr_mat

Numeric matrix, genes × samples, log2(TPM + 1) values.

meta

Data frame of clinical metadata, one row per sample.

project

Project ID string.

data_type

Data modality used.

backend

Download engine used.

Details

The returned list can be passed directly to SurvMetaSummary to explore available clinical columns before calling SurvPlot.

Examples

if (FALSE) { # \dontrun{
gbm <- LoadTCGA("TCGA-GBM")
SurvMetaSummary(gbm$meta)
SurvPlot(expr_mat   = gbm$expr_mat,
         meta       = gbm$meta,
         genes      = c("YAP1", "S100A4"),
         time_col   = "OS",
         status_col = "status",
         facet_row  = "gender",
         facet_col  = "paper_IDH.status",
         output_file = "~/Desktop/GBM_survival/")
} # }